How can I obtain/process polygon data regarding roads from Open Street Maps - rendering

I've been looking through Open Street Map's and for general interest I wanted to be able to use a programming language e.g. python to render the streets graphically. Not by using map tiles, but by analysing the data and drawing my own polygons/lines.
I've obtained a OSM Shapefile(The shapefile is a common standard for representing geospatial vector data.) and I've converted it to a JSON file to make it readable for my own understanding.
When the shapefile is imported into QGIS it will fully represent the street system as it was on OSM. But when I look through the JSON file, there are coordinates, but not enough data to build polygons of streets.
A single street looks like this:
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[151.1734844,-32.5675228],[151.1735678,-32.5670849],[151.173932,-32.5671361]]},"properties":{"osm_id":"559250924","bridge":"","highway":"service","layer":"","name":"Maple Lane","oneway":"","smoothness":"","surface":"","tunnel":"","width":"","z_index":"3"}},
Each street will contain a different number of coordinates. But as I stated before there is not enough to go off to construct a street layout.
How do I find the data in a shapefile to construct my own street layout? It should be there, as QGIS is achieving this with the files I uploaded.
Thanks for any help

Related

How to have continuous features for a shapefile and get rid off the wrapdateline?

How to have continuous features for a shapefile ?
I mean NOT cut by the dateline to respect [-180:180] longitude excursion that I do not
want to respect.
Here is an example where I display the Russia shapefile in a leaflet map.
In fact I would like to have continuous continent.
Shapefile comes from
https://gadm.org/about.html
Any command from gdal or ogr2ogr to merge separated features ?
Thanks
If you load the GADM level-0 layer into QGIS and toggle Show Feature Count, you'll see that, even though the shape seems split, the actual layer only has a single feature:
Your shape gets cut off because the polygon crosses the boundary in the projection you are using and gets wrapped around. This doesn't mean the features get actually split.
If you want to display it as a continuous feature, you need to specify an appropriate projection. For instance, using the example here gives me this:
This is just one way, there might be different projections that fit your purpose better. Also, getting this done in leaflet is a different question.

GPS coordinates analisys library

I am working on a project where I save the Latitude and Longuite of a vehicle each an interval. I have also a route saved as an array of gps coordinates. So I would like to know if there is some library, that helps me to know if a point is inside the rout and other basic calculations with the coordinates as distance calculations for ex.
Any tool an any language helps!
Based on your comment, since you're not building a typical internet map, I might recommend you use a combination of Python and the Shapely library. You can see some nice examples on this post over at GIS.SE.
GIS Analyses: Geometry Types, Buffering, Intersection, etc.
In order to treat several individual Lat/Long positions as a "route", you'll need to format them as points in a LineString geometry type. Also beware: In most GIS software, points are arranged as X,Y. That means you'll be adding your points as Long,Lat. Inverting this is a common mistake that can be frustrating if you're not aware of it.
Next, in order to test whether any given point is within your route, you'll need to Buffer your route (LineString). I would use the accuracy of the GPS unit, + a few extra meters, as my buffering radius. This will give you a proper geometry (Polygon) for a Point-In-Polygon test (i.e. Intersection) that will calculate whether a given point is within the bounds of the route.
The GIS.SE post I linked to provides examples for both buffering and intersection using Python and Shapely.
Some notes about coordinates: Geodetic vs. Cartesian
I'm not confident if Shapely will perform reliable calculations on geodetic data, which is what we call the familiar coordinates you get from GPS. Before doing operations in Shapely, you may need to translate your long/lat points into projected X/Y coordinates for an appropriate coordinate system, such as UTM, etc. (Hopefully someone will comment whether this is necessary.)
Assuming this is necessary, you could add the PyProj library to give you a bridge between the GPS coordinates you have and the Cartesian coordinates you need. PyProj is the one-size-fits-all solution to this problem. However if UTM coordinates will work you might find the library cited here to be easier to implement.
If you decide to go with PyProj, it will help to know that your GPS data is described by the EPSG:4326 coordinate system. And if you are comfortable with UTM for your projected coordinates, you'll need need to determine an appropriate UTM zone for your area and get its Proj4 coordinate definition from SpatialReference.org.
For example I live in South Carolina, USA, which is UTM 17 North. So if I go to SpatialReference.org, search for "EPSG UTM zone 17N", select the option which references "WGS 1984" (I happen to know this means units in meters), then click on the Proj4 link, the site provides the coordinate system definition I'm after in Proj4 notation:
+proj=utm +zone=17 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
If you're not comfortable diving into the world of coordinate systems, EPSG codes, Proj4 strings and such, you might want to favor that alternate coordinate translation library I mentioned earlier rather than PyProj. On the other hand, if you will benefit from a more localized coordinate system (most countries have their own localized systems), or if you need to keep your code portable for use in many areas, I'd recommend using PyProj and make sure to keep your Proj4 definition string in a config file, and NOT hard-coded throughout your app!

Creating a Choropleth Map at the County Level

I'm trying to create an animation of the population density of the Appalachian region from roughly 1790 to 2010 in decennial steps at the county level.
I've successfully created a choropleth for 2010 by modifying what was done in this tutorial by Nathan Yau. I've run into a few problems. For one, US county boundaries evolve rapidly over time so I can't use the same SVG file as in the tutorial. I think I need to do the following:
Obtain historical county boundaries as GIS files from here.
Convert GIS files into SVG files using Kartograph (after installing its numerous dependencies).
Obtain population data (with FIPS info) for each county in Appalachian region since 1790 from US census data.
Mimic what was done in tutorial to create choropleth for each decade and stitch together into animation.
This just seems insanely complicated for something so simple and I'm new to a lot of this so I'm not convinced I'll be able to get all of it to work. I guess my questions are the following:
Will the strategy I outlined work? Is there a better/simpler way to do what I'm trying to do?
Also, as for getting the census data, this also seems harder than it has to be. I just want a simple .csv file with say FIPS label, county name, and population for a given year, and yet the best I can find is something like this with a link to the actual source in some arcane format.
Thanks for any help!
You can download tables of population data by county from the US Census here:
http://factfinder2.census.gov/faces/tableservices/jsf/pages/productview.xhtml?src=bkmk

Dynamically overlaying vector graphics on a PDF

I have a particular requirement to generate a PDF document with some dynamic data overlaid on top.
That's the general gist. To be clear, I have a fair amount of experience in generating PDFs programatically so I'm not looking for a list of products that can simply churn out PDF.
The specifics are:
I have a pre-existing PDF template containing a vector representation of certain regions of the UK. I will be capturing geographical data via a web interface and will need to overlay these data on the PDF as vector graphics (little circles with numbers to be specific).
So, what I'm looking for is some advice on:
How to dynamically write vector graphics to a PDF
Translation of geographical coordinates to vector layer coordinates
Cheers.
Steve
iText[Sharp] can handle the vector graphics portion fairly easily with a PdfStamper.
There have been several questions on the itext-questions mailing list about geographic coordinates that should help you on that front as well. Searching your favorite list archive for "geospatial" should turn them up.
I don't think we've added higher-level functions for that sort of thing yet, so you'll have to dig into PdfDictionary, PdfArray, and so forth. Keep a copy of the PDF Reference handy (but you probably already do).

Roads Shapefile Names

I have a shapefile with a road network and it seems like the roads are all listed as 1 big polyline. Is this typical is it possible to get a road network where the roads are listed individually and have names associated with them?
thanks,
Jeff
If someone sent me a shapefile of roads where all the roads were a single polyline, I would assume the person was playing a practical joke on me.
Typically, a useful shapefile of roads would at least be broken into a single line for each defined road, or even better, a network intersection-to-intersection segment shapes.
It's not a trivial task to split up a single polyline into a more useful multi-segmented shapefile.
Doing a quick Google search returns a couple of free solutions for shapefile editors although I can't vouch for any of them. I use my company's own codebase written in C# using Tatuk for working with shapefiles.
http://www.nrdb.co.uk/nrdbview/
http://www.forestpal.com/blog/?p=21