What forecasts in r will feed the city map?

I am trying to make some city maps, and I would like to distort them a bit, so the densest parts (manhattan in this case) are apparently a bit wider on the last map. I find it hard to find good projection examples at the city level.

I would like the projection to make a more beautiful map of New York, but it may be too subjective, so let me say that I want to fatten Manhattan. The reproducible code of what I tried below:

library(ggplot2) library(maptools) shpny.tf <- tempfile() download.file( "http://www2.census.gov/geo/tiger/TIGER2010/COUNTY/2010/tl_2010_36_county10.zip" , shpny.tf , mode = 'wb' ) shpny.uz <- unzip( shpny.tf , exdir = tempdir() ) ny.shp <- readShapePoly( shpny.uz[ grep( 'shp$' , shpny.uz ) ] ) # limit the shapefile to only the five boroughs nyc.shp <- subset( ny.shp , as.numeric( as.character( COUNTYFP10 ) ) %in% c( 5 , 47 , 61 , 81 , 85 ) ) # prepare for plotting nyc <- fortify( nyc.shp ) # make a plot p <- qplot( data = nyc , x = long , y = lat ) # default plot p # these two seem like good candidates for fattening, # but i'm not sure how to make them take up more space on the right and left side p + coord_map("ortho", orientation=c(41, -74, -25)) p + coord_map("azequalarea",orientation=c(41,-74,-22)) # this one okay but still not ideal p + coord_map("lagrange") # this one is named for new york yet i can't get it to do anything useful p + coord_map("newyorker",r=10) 

ideally, the result will look closer to the proportions in this New York subway map. I understand that this major part of the distortions is impossible only when projecting, I’m just curious if any forecasts can make the map closer to this ideal shape. thanks!

enter image description here

+5
source share
5 answers
 # this is clearly insane p + geom_map(map=nyc, aes(map_id=id, group=group), fill="white", color="black") + coord_map( "globular" , orientation = c( 40.55 , -74.11 , -24 ) ) 

enter image description here

0
source

I uploaded the shapefile and saved it, as constantly downloading the 1M file has dubious efficiency. Since I did this with curl on the command line, I was already in the terminal, so I pre-extracted five areas using ogr2ogr :

 $ ogr2ogr -f "ESRI Shapefile" \ -where 'COUNTYFP10 IN ("005", "047", "061", "081", "085")' \ boroughs.shp tl_2010_36_county10.shp 

Then I read the new shapefile using readOGR and installed some necessary libraries:

 library(rgdal) library(maptools) library(ggplot2) boroughs.shp <- readOGR("tl_2010_36_county10/", "boroughs") 

Now we separate New York and the other four cities:

 nyc <- boroughs.shp[boroughs.shp$NAME10 == "New York",] other_four <- boroughs.shp[boroughs.shp$NAME10 != "New York",] 

Read ?elide as it allows you to scale the polygons and move them, and you will need to do more than what is shown in this example. Here I scale nick to 1.1 (arbitrary), but keep the 1: 1 scale for the rest. I take a little shortcut here and do it since elide changes CRS for SpatialPolygonsDataFrames.

 nyc <- elide(nyc, scale=1.1) other_four <- elide(other_four, scale=1) 

Then we combine them again:

 boroughs.shp <- spRbind(nyc, other_four) 

and do the necessary work for ggplot:

 boroughs <- fortify(boroughs.shp, region="NAME10" ) 

I prefer geom_map and this gives you adjacent polygons against your site:

 gg <- ggplot(data=boroughs, aes(x=long, y=lat)) gg <- gg + geom_map(map=boroughs, aes(map_id=id, group=group), fill="white", color="black") gg <- gg + coord_map() gg 

enter image description here

This is obviously not the final state you want, but now you have the tools you need to build the correct cartogram (although I personally am not a fan of distorted polygon maps).

You can learn more about creating cartograms to get the final effect, but it will take even more effort. Real cartograms are the way here, IMO, if you want to do fattening / scaling to show density.

EDIT OR maybe just install for globular ?

 gg_globular <- gg + coord_map("globular", orientation=c(41,-74,-22)) + ggtitle("globular") 

enter image description here

+4
source

In the spirit of cartograms, you can combine R with a cross-platform Java program, ScapeToad . Clearly, this is not as desirable as a pure-R solution, but this is an option anyway.

For instance:

 # Create a field that will be used to distort polygons. # In our case, the second polygon corresponds to New York County (ie Manhattan) ny.shp$size <- c(1, 1.5, 1, 1, 1) 

Now let's move on to ScapeGoat and generate a cartogram using the size field as an attribute of the cartogram and export as .shp.

This causes the following:

enter image description here

Obviously this approach is less suitable if you need accurate grid lines.

+1
source

Pseudocode for the solution in any language that is most convenient for you to write. This approach allows you to apply different levels of distortion to different parts of the map, while maintaining the topology of the common edges.

I suspect that a mess with different projections is unlikely to lead to noticeable distortion in such a small geographical area.

In any case, that’s how I approach him.

  • Dump the points of each polygon, as well as poly_id and index position.
  • Select a breakpoint. For example, the center of gravity of your dense polygon
  • Calculate the azimuth and distance between each point (step 1) and the reference point (step 3).
  • Create a translation function with any parameters you want. It may just be a function of distance, keeping the azimuth constant or distance and sin azimuth, etc., if you want to distort more in a particular plane.
  • Calculate the new x, y of each politochka
  • Return polygons.

I can already imagine a great data animation showing morphing forms over time. When I get some time, I will encode the solution and share. NTN

+1
source

http://kartoweb.itc.nl/geometrics/coordinate%20transformations/coordtrans.html

Refer to the theory.: - (((

My recommendation would be to do all your analysis using your current CRS.

I would then distort your results by vectorizing each layer, including rasters (for example, centrifuges of pixel pixels). Then I would apply the translation function to distort the functions of each vector object in the same way. Then I would re-rasterize your Kriegged grades.

My pick tool for this is postgis using ST_translate. Then I returned the data to R to create new raster surfaces for visualization purposes.

0
source

Source: https://habr.com/ru/post/1205214/


All Articles