Buffer geocoded Address

1024
5
Jump to solution
10-10-2018 09:00 PM
AhmadSALEH1
Occasional Contributor III

Hello,

I am using Python API to geocode a list of address, then buffer the geocoded address by 1 mile, what I have so far:

addlist=['adress1',
         'address2',
         'address3']

bgeocode=batch_geocode(addlist)


for address in bgeocode:
   

 poly=buffer(geometries=[Geometry(address['location'])],in_sr=3857,
            distances=[1],unit='Miles')[0]
    
 m1.draw(poly)



‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The result:

Now my question is why the result buffer looks like an ellipse not a circle? also, the circles are more than 1 mile ? is there another method to buffer the address and show them on the map, because here I am using the buffer for each address?

Thank you,

Ahmad 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
simoxu
by MVP Regular Contributor
MVP Regular Contributor

The buffer function is a bit confusing and clunky, here is what I mean:

When you specify the in_sr value, the unit parameter is not relevant any more. for example, if you specify in_sr=4326, the unit will be "degree" regardless whatever value you specify for the unit parameter. if you set in_sr=3857, the input values will be "Meters".

In regard to which projection to choose, for a 1 Mile radius circle, you should not see big difference between SRID 3857 and a relative accurate local projection --- the distortion caused by projection become more visible over long distances or large areas.

I would recommend to use use_proximity.create_buffers() for your task.

addresses = ['Adelaide, South Australia',
            'Mount Barker, South Australia',
            'Brookside St, Oakden,South Australia']
results = batch_geocode(addresses)

fs=[Feature(geometry=Geometry(res['location'])) for res in results]
fset = FeatureSet(fs)

sms = {
    "color": [255,0,0,150],
    "size": 10,
    "angle": 0,
    "xoffset": 0,
    "yoffset": 0,
    "type": "simple-marker",
    "outline": {
        "color": [
            255,
            255,
            255,
            255
        ],
        "width": 1,
        "type": "esriSLS",
        "style": "esriSLSSolid"
    }
}

for res in results:
    map1.draw(res['location'],symbol=sms)

prox=use_proximity.create_buffers(fset.to_dict(),distances=[1],units='Miles')
map1.add_layer(prox)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

5 Replies
simoxu
by MVP Regular Contributor
MVP Regular Contributor

This looks like an issue related to wrong map projection.

The World Geocoding Service spatial reference is 4326 (a.k.a WGS84)

So try this if you want to use SRID 3857 (same as ESRI 102100):

bgeocode=batch_geocode(addlist,out_sr=3857)
DanPatterson_Retired
MVP Emeritus

Those buffers are also in the units of the data... and certainly are not 1 mile. 

And any web projection isn't really good for distance or direction (especially web Mercator and its ilk), so if that is most important try something like https://epsg.io/5070  which is think is used in the U.S.

Melita Kennedy‌... sorry, could you check my suggestion for this webby world

MelitaKennedy
Esri Notable Contributor

I assume the center of the buffers are in the correct locations? If certainly looks like the buffer distance was treated as 1 degree, rather than 1 mile. Projected into Web Mercator (EPSG:3857), the north-south distance would get stretched because that's what Mercator does to maintain conformality (local angles/shapes).

Maybe try something like:

buffer(geometries=[Geometry(address['location'])],in_sr=4326,distances=[1],unit='Miles',out_sr=3857,buffer_sr=4326,geodesic=true)

simoxu
by MVP Regular Contributor
MVP Regular Contributor

The buffer function is a bit confusing and clunky, here is what I mean:

When you specify the in_sr value, the unit parameter is not relevant any more. for example, if you specify in_sr=4326, the unit will be "degree" regardless whatever value you specify for the unit parameter. if you set in_sr=3857, the input values will be "Meters".

In regard to which projection to choose, for a 1 Mile radius circle, you should not see big difference between SRID 3857 and a relative accurate local projection --- the distortion caused by projection become more visible over long distances or large areas.

I would recommend to use use_proximity.create_buffers() for your task.

addresses = ['Adelaide, South Australia',
            'Mount Barker, South Australia',
            'Brookside St, Oakden,South Australia']
results = batch_geocode(addresses)

fs=[Feature(geometry=Geometry(res['location'])) for res in results]
fset = FeatureSet(fs)

sms = {
    "color": [255,0,0,150],
    "size": 10,
    "angle": 0,
    "xoffset": 0,
    "yoffset": 0,
    "type": "simple-marker",
    "outline": {
        "color": [
            255,
            255,
            255,
            255
        ],
        "width": 1,
        "type": "esriSLS",
        "style": "esriSLSSolid"
    }
}

for res in results:
    map1.draw(res['location'],symbol=sms)

prox=use_proximity.create_buffers(fset.to_dict(),distances=[1],units='Miles')
map1.add_layer(prox)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

AhmadSALEH1
Occasional Contributor III

Thank you All, it was really tricky, but Simo's method did the job perfectly. 

0 Kudos