I have this interesting challenge in my work, i have shape files of road networks, and another shape-File containing area boundaries, is there any tool that i can use to get length of roads that lies inside each polygon?
I have access to both QGIS and ArcGIS.
This is probably better asked on gis stackoverflow.
That said, this is a multi-stage problem. I'd suggest something like:
Clip the roads layer by the polygon layer, keeping the polygon id for each road.
Measure the length of the now-clipped roads.
Sum up the road lengths, grouping by the polygon_id
Join the now-measured,-summed-and-clipped roads layer back to the polygon layer.
This will give you what you want.
If you don't know how to use QGIS/ArcGIS, try googling for tutorials (or get work to splurge on training). There are plenty that cover the above functions.
Related
I'm working in QGIS but I can also use ArcGIS if there's a solution that works best on there.
I have a shapefile with certain plots of land highlighted and I plan to calculate the distance of features to the borders of these plots. But the plots have the roads and rivers going through them as gaps in the polygons. Like this:
Of course, this messes with the distance calculation I want. The goal is to create new polygons that just the outline only. I have tried the hole function in QGIS. I also tried buffering with dissolving then reversing the buffer. What other methods might work to fill in the gaps?
Background
We are supplied with some AIXM data (an XML based superset of GML) which describes polygon areas on a map as a mix of GeodesicStrings (a list of coordinates) and ArcByCentrePoints (a centre point coordinate with a radius, start bearing and end bearing). We are taking this data and converting it into a simple list of coordinates that we then display using a Google maps polyline.
Problem
When we plot a shape with an arc, the start and end points of the arc usually don't match up with the end point of the preceding line and the start point of the subsequent line. It looks as if the radial distance is out by an amount which doesn't appear to be proportional to the radius. See screenshot: interestingly the smaller arc at the top seems fine but the larger arc is inset.
We're pretty sure the data is correct because it looks fine when we use a third party tool to visualise it, so we're doing something wrong.
Implementation
We are using the turf.js library to convert the arc description into a set of points using their lineArc function. Internally this utilises their destination function which "uses the Haversine formula to account for global curvature". We combine these generated points, in the correct sequence, with the points taken directly from the preceding and subsequent GeodesicString elements to give us our final polygon.
Data
Input: Fragment of AIXM (GML) describing polygon
Output: Resulting list of points
Help!
I'm aware this question is light on code but I hope I've described the problem adequately and that some kind person with more GIS knowledge than me (>0) might be able to point me in the right direction. Thanks :)
I've given a couple of presentations on debugging and one of the things I say is that you should keep an open mind and shouldn't get too fixated on a possible cause of a bug because you can waste a lot of time tracking down a false lead.
Sadly in this case I didn't take my own advice. I was so obsessed with the idea that the problem arose from a complex cause, such as issues with the implementation of the Haversine formula, that I overlooked the far simpler answer. My code was taking a string representation of the radius, including the units (e.g. nautical miles or meters) and converting it into kilometres. Sadly I was using parseInt rather than parseFloat as part of this and so instantly losing precision. It was a simple as that - a schoolboy error.
Big thanks to Stefano Borghi, a maintainer of Turf JS, for all his help with this and for helping me see the wood for the trees.
Is it possible to determine if a gps point is in water or near(not including elevation) . From what I have seen it doesn't seem possible. I had an idea of somehow getting the gps fence of water bodies and checking if the point lays in the fence. Sounds good but I can't find gps coordinate fences. If any one have any other ideas or a place to get those fences it would be great.
You can get the GPS fence for water from OpenStreetMap.
Then you do a point in polygon operation, optionally you put all polygons in
a spatial search structure, like a quad tree, for a fast polygon search nearby the lat,lon point.
You can start here. and later read more how to identify water in OpenStreetMap
A solution that works on small areas of waters, worldwide, would use much storage space If you concentrate on some countries this should work.
I found that the article is a very interesting approach.
Using google static maps to draw just some pixels around your coordinates, and then check whether its blue or not blue.
You can set a custom unique colour for "water" as a parameter to the google static map, which makes it easy for you to determine if it matches water or not
We hear a lot about CRS in GIS. I am working with QGIS and whenever I add a layer I need to specify the CRS but what I am confused about what exactly is a CRS and how is it different projection system. Why do countries have their own CRS and how is it determined?
If I understood the question correctly, most APIs use the WGS84 format to specify geographical coordinates, which is briefly explained in this Wikipedia article. Basically, the coordiantes are polar coordinates referring to an ellipsoid whose center is located at earth's center of gravity.
The earth is a sphere, and not a completely round one. However we would still like it as if it was flat to make proper maps and make measurements.
For example, using WGS84 on a map of Norway would make it look horribly distorted.
that is why different regions have their own projections for their own cartographic needs.
I found a good definition of a CRS here. For al intends and purposes it is the same as its projection.
I'm working on the following scenario: I have a geographical location and I need to create a heat-map visualization of travel times (by car) from that location to anywhere around. I'm planning on using Google Distance Matrix API for getting travel duration. But, since it has a limit on the no of API calls, I need to somehow limit the calls.
My plan, so far, is the following: compute the travel duration (basically a numeric value) to a set of points evenly distributed on a grid around the given position (e.g. 0.5km east, 0.5 km east-0.5km north, 0.5 km east-1 km north etc.). This points would represent the centers of square-shaped areas and I will consider the travel duration to the center as the travel duration to anywhere in the area. Display these areas as colored squares on a Google Maps in a heatmap style.
A good example of something that looks alike is this: http://project.wnyc.org/transit-time/#40.72280,-73.95464,12,709 .
So, my questions are:
Does it seem like a good strategy?
Is there a better visualisation strategy for something like this?
How can I create those square-shaped colored areas on Google Maps?
Thanks!
Calculating duration would surely involve traffic flow rather than simply distance. If your calculations are purely on distance you could use the Google Maps direction requests to calculate the distance to each point.
I'm not sure a heat map is the way forward for this scenario.
There a number of way you could achieve this. Here's a few:
a. Use a custom overlay
(https://developers.google.com/maps/documentation/javascript/examples/overlay-simple)
b. Draw polygons on the map and give them different colours based on
the journey duration. This would involve taking the area in question and slicing it up in to polygons however you need to. These polygons could take the same shape as your example. You would need to be rather precise with your latlng. SQL's spacial querys would help you here depending on the tech your using. (https://developers.google.com/maps/documentation/javascript/examples/polygon-arrays)
c. Depending on how specific you wanted to be you could draw circles with different radius value and different colours.
d. You could make custom markers in the shapes you require and add them to the map in the correct latlng in order to fill an area. You could have different markers for different duration and add them accordingly.
I'm sure there are other options as well.