We have a situation that is described below. We are trying to show the competitor information. The map has three layers.
We would like to print each 10KM circle area, the main Starbuck Coffee Store and the competitor coffee shops to one pdf. We will get 100 pdfs for the 100 stores. The sample is like below:
Is there a way that we can quickly create 100 maps with circles and corresponding information?
We are using ArcGIS online. Thank you in advance.
Is it possible? Definitely! Easily, and with off-the-shelf tools? Not so much.
Still, it's a relatively straightforward process, and could be accomplished without too much trouble with a bit of Python. Is that an option for you?
Hi Josh,
Thank you so much for the reply. I know how to program in Python but I have never used ArcGIS library. Would you be able to provide some details? Where can I start? Thank you so much.
Believe it or not, but I think you'd be better served using something like GeoPandas for this. I say that because while the ArcGIS Python API has extensive "mapping" capabilities, it is entirely focused on interactive map "widgets", and does not do as well with exporting nice-looking static images.
GeoPandas, on the other hand, can work seamlessly with MapPlotLib to make really nice maps, which you can then include in a PDF.
import geopandas as gp
import requests
layer1_params = {
'where': '1=1',
'outFields': 'some, field, names',
'f': 'geojson'
}
layer1 = requests.get('your-service-url/query?', layer1_params)
df1 = gp.read_file(layer1.text)
circ = df1.buffer(10000) # this assumes input df1 is in meters. this is dependent upon the spatial reference your layer is in. you can optionally request the parameter 'outSR' to change this at the request level
layer2_params = {
'where':'1=1'
}
layer2 = requests.get('other-service-url/query?', layer2_params)
df2 = gp.read_file(layer2.text)
n = 0
# iterate over features in first layer
while n < len(df1):
# get shape of feature
shp = df1.loc[n, 'geometry']
# plot the shape
m = shp.boundary.plot()
# subset second layer for features in circle, add to plot
df2[df2.within(shp)==True].plot(ax=m)
n += 1
For the PDF portion, I don't have a handy example, but this post looks pretty useful: https://datatofish.com/export-matplotlib-pdf/
It's just a start, but you'll find plotting in GeoPandas very easy to configure.
Thank you so so much!
In your code,
layer1 = requests.get('your-service-url/query?', layer1_params)
layer2 = requests.get('other-service-url/query?', layer2_params)
I guess the url is the published map's URL which is shared. All these have nothing to do with ArcGIS api. I can write the script on my local machine and grab the data, plot it, and print out. Will the base map information and points be the same as they are in ArcGIS?
I will try the solution. Thank you!!!
Hm, good question. I don't typically work with basemaps when I'm plotting in GeoPandas, but I'm sure it's possible.