How to use the arcgis.geometry.Polygon function in arcgis

To help you get started, we’ve selected a few arcgis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngageoint / state-of-the-data / state-of-the-data-for-webgis / osm_runner / runner.py View on Github external
w_tags = w['tags'].keys()
        for tag in w_tags:
            if tag not in val_dict.keys():
                val_dict[tag] = []

    # Build Lists
    for w in ways:
        try:
            # Populate Tags
            for tag in [key for key in val_dict.keys() if key != 'osm_id']:
                val_dict[tag].append(str(w['tags'].get(tag, 'Null')))

            # Populate Geometries & IDs
            coords = [[e['lon'], e['lat']] for e in w.get('geometry')]
            if g_type == 'polygon':
                poly = Polygon({"rings":  [coords], "spatialReference": {"wkid": 4326}})
            else:
                poly = Polyline({"paths": [coords], "spatialReference": {"wkid": 4326}})

            geo_dict['geo'].append(poly)
            val_dict['osm_id'].append(str(w['id']))

        except Exception as ex:
            print('Way ID {0} Raised Exception: {1}'.format(w['id'], str(ex)))

    try:
        return SpatialDataFrame(val_dict, geometry=geo_dict['geo'])

    except TypeError:
        raise Exception('Ensure ArcPy is Included in Python Interpreter')
github ngageoint / state-of-the-data / src / runner / osm_runner.py View on Github external
def build_ways_dict(n_list, g_type, w_list):

    way_dict = {"ids": [], "names": [], "geoms": []}

    for w in w_list:
        try:
            coords = []
            for w_n in w['nodes']:
                for a_n in n_list:
                    if a_n['id'] == w_n:
                        coords.append([a_n['lon'], a_n['lat']])

            if g_type == 'polygon':
                poly = Polygon({
                    "rings": [coords],
                    "spatialReference": {"wkid": 4326}
                })

            else:
                poly = Polyline({
                    "paths": [coords],
                    "spatialReference": {"wkid": 4326}
                })

            _name = 'Undefined'
            tags = w.get("tags", None)
            if tags:
                name = tags.get("name", None)
                if name:
                    _name = name