2

I wish to plot a 2d density map atop of a city, Washington DC in this case.The 2d density estimation graph is created using plotly and the points are graphed by their latitude and longitude. I have looked at basemap but it seems that you can only draw state boundaries, and cannot get city boundaries and streets on the map. I didn't seem to find a way to do it with google maps api either. Problem: Can't display streets in basemap.

namehandles
  • 21
  • 1
  • 3
  • 1
    *Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.* – m02ph3u5 Apr 10 '16 at 19:54
  • have a look into shape files and the shapely package. cartopy is also an alternative to basemap. – MaxNoe Apr 10 '16 at 20:30

2 Answers2

2

Arcgis has quite a few maps available online, that are accessible straight from matplotlib basemap, via the arcgis REST API.

It's not mentioned in the matplotlib manual, but I have found out about it on another site.

Personally, I have mostly worked with Elevation/World_Hillshade, but that looks like they also have a streetmap on offer.

test_map = Basemap(llcrnrlon=15.2,llcrnrlat=47.06,urcrnrlon=15.5, urcrnrlat=47.49, epsg = 31284,resolution='i',projection='merc',lon_0=14.8,lat_0=47.2)


test__map.arcgisimage(service='ESRI_StreetMap_World_2D', xpixels = 12000, verbose= True)

Gives me the below plot for a random area I just had in my cache:

lowres image of roads

Main issue I am having is the epsg part, which I havent fully figured out, so cant help you there for Washington DC

JC_CL
  • 2,346
  • 6
  • 23
  • 36
  • The `epsg` value can be retrieved from here: https://spatialreference.org/ref/?search=&srtext=Search – Arraval Jul 01 '19 at 11:21
0

I have got a slight idea of using the epsg value.

  1. Go to the link http://spatialreference.org/ref/?search=california&srtext=Search Try to find the place you are searching, I have used california for example
  2. Open one of the links from all the links which closely resembles the area you want to map. I have taken this for example: http://spatialreference.org/ref/epsg/2228/
  3. You should be able to see the WGS84 Bounds which tells the bounds for this map
  4. Now you are free to use any bound between this bounds in your map and use the epsg value given

example code for sacramento:

**plt.figure(figsize=(18,20))
test_map = Basemap(llcrnrlon=-121.900, llcrnrlat= 38.50, urcrnrlon=-121.00, urcrnrlat=38.7000, epsg = 2872,resolution='i',projection='merc',lon_0=14.8,lat_0=47.2)
#sacramento : 38.5816° N, 121.4944° W
#-123.0900, 36.7400, -117.8200, 38.7000
test_map.arcgisimage(service='ESRI_StreetMap_World_2D', xpixels = 12000, verbose= True)**
sietschie
  • 7,425
  • 3
  • 33
  • 54
solve it
  • 174
  • 1
  • 6