Why is my GIS Shapefile (CRS 4326) not viewed from directly above? - r

I have loaded two shapefiles into Netlogo. One shapefile's original projection was 4326 (osmdata) and one was originally 28992 (Dutch government data) which was st_transformed(4326) in R. When I load them into Netlogo, it does not display the shapefile directly from above, which it does do from R ggplot
Why is this and how do I get it viewed from above?

It was solved by using gis:set-world-envelope-ds instead of gis:set-world-envelope

Related

geoviews/geopandas/shapely problem displaying polygons from a shapefile

I am trying to overlay a shapefile representing the range of Coast Redwoods onto some other data I'm processing in geoviews. I can successfully plot the data using cartopy and matplotlib. GeoPandas reads the shapefile, but passing the GeoDataFrame or individual shapely polygons to gv.Shape (as in the geoviews user guide under "Shape") consistently results in
AttributeError: 'list' object has no attribute 'xy'
I am not sure whether the problem is in Shapely or in Geoviews. I suspect geoviews because geopandas is able to reproject and plot the polygons.
I've put up a notebook demonstrating the problem and providing the shapefile.
Any help or ideas much appreciated.
I was having the same issue, then i went ahead and converted my GeoDataFrame to EPSG:4326 as follows:
projected_df = original_df.to_crs('EPSG:4326')
Originally I was in EPSG:4269 (Albers Equal Area) and thought adding that to an Albers Equal Area projection would work but I think you need to start your data with EPSG:4326 and then work with projections with Geoviews.
Let me know if that does the trick.

Adding geography to tmap World data frame

I need to map data of South America and the Caribbean, including small geographies such as St. Vincent and the Grenadines. However, in the World data set with the tmap library these are not included. Using the included spatial data base of the tmap library seems easier than finding, loading, parsing and cleaning a different shape file from some other sources. Is it possible to insert these countries or should I just fight through learning the details of GIS just to draw a simple thematic map of the Caribbean?
I have battled with reading shape files from OSM today and other mapping packages. Tmap is a great approach for us non-GIS professionals.
Thanks for any direction you can give.

Display only a single state with ggmap

Is there a simple way to display only a single state? For example
qmap("Texas", zoom=6)
produces
which obviously also includes all of Oklahoma, most of New Mexico, etc...is there a way to "mask" the surrounding states (and Mexico) to display only Texas?
The short answer is that you need to tell ggmap where Texas is. Typically you'd do that using a shapefile. See e.g.
R: ggmap – Overlay shapefile with filled polygon of regions
Plotting Choropleths from Shapefiles in R with ggmap

Adding Boundaries to Spatial Polygons Object

I have the following SpatialPolygonsDataFrame.
require(raster)
usa <- getData('GADM', country='USA', level=2)
metro <- subset(usa, NAME_1=="Nebraska" & NAME_2 %in% c("Dodge","Douglas","Sarpy","Washington"))
plot(metro)
I would like to be able to replicate the following map boundaries (defined by the colors):
Does anyone know a good plan of attack? I realize this is a somewhat manual process. I have already downloaded all US Census files that are of a more detailed geography. I was hoping that a more detailed level of geography could be aggregated to answer the above question, but unfortunately the districts do not line up the same.
Is there a R function already out there that would be helpful in assisting this manual process? At the very minimum, I would like to be able to leverage the perimeter of the 4-county area.
Use writeOGR from the rgdal package to create a shapefile of your metro object. Then install QGIS (http://www.qgis.org/), a free and open-source GIS, and load the shapefile as a new layer.
Then you can edit the layer, add new polygons, edit lines etc, then save as a shapefile to read back into R.
Additionally, you may be able to "georeference" your image (by identifying known lat-long points on the image) and load that into QGIS as a raster layer. That makes it easier to digitise your new areas. All you need for that is a few lat-long coordinates of specific points, such as the corners of polygons or line intersections, and then QGIS has a georeferencing plugin that can do it.
I don't think you'll find any R code as suitable for digitising new geometries over an image as good as QGIS.
After half an hour (and twenty years experience, not all of which you'll need) I've got this:
I didn't precisely digitise your new boundaries though, just roughly for speed. That QGIS screen cap shows the five coloured areas under the four metro areas.
Step one was georeferencing. This screengrab shows how the PNG has been georeferenced - the red line is the metro area shapefile drawn with transparency over the PNG after the PNG has been converted to a GeoTIFF by matching control points.
Step two was then using QGIS editing tools to split, join, and create new polygons. Then I just coloured them and added labelling to pretty it up.
I could probably bundle these files all up for you to neaten, but it really doesn't take that long and you'll learn a lot from doing it. Also, this is probably a gis.stackexchange.com question...

Themathic map/choropleth map of the Netherlands

I have a bunch of data on Dutch individuals that I would like to visualize with a choropleth map. I also have the location of the individuals (longitude and latitude), so I was hoping that it would be possible to visualize that on a Dutch map that is divided into municipalities (="gemeente" in Dutch), so I can color each municipality according to the mean value of all individuals living there. I know that the R package maptools can make choropleth maps, but I believe that it requires template maps in the form of a .shp file. Does anyone know where I could find such a template for the Netherlands? Preferably with municipalities and NOT per province, so for this image it would be the one on the left:
(source: www.kb.nl)
Any suggestions for other packages/software/etc to do this are also welcome! Many thanks!
also try GADM: http://www.gadm.org/
This site is an excellent resource, extra bonus: .Rdata is one of the formats you can download in (containing a SpatialPolygonsDataFrame). They also have .shp format, for your case.
Your main problem will be finding a shapefile for the municipalities. Once you have that and can easily relate your data at the lat/long level to the municipalities, then plotting becomes easy.
ggplot2 is a fantastic example.
Choropleths in R is a potential example, because it does not use shapefiles, but I believe the maps package supports it
Failing that, you could always try Weave
There are various .shp files for the Netherlands here:
http://www.eea.europa.eu/data-and-maps/data/eea-reference-grids/
You might also be able to find the municipalities layer on GeoCommons and join your data with one of those layers. GeoCommons makes it really easy to make many different choropleth maps quickly.
Another source for shapefiles at Eurostat is here. However, with a restrictive license, and I believe only at NUTS3 level (I did not look at it, though).
Open Streetmap does contain administrative boundaries,but not as polygons. Here is a report about how to transform boundaries to polygons. (I did not try)
You can find recent official Dutch maps here: https://www.pdok.nl/nl/producten/pdok-downloads/basis-registratie-kadaster/bestuurlijke-grenzen-actueel in .gml and .xsd formats (not in .shp unfortunately). National borders, province and municipality.

Resources