예제 #1
0
def latlon_to_swiss(latlonPoint):
    """
    Takes a [lat, lon] (y, x) point and returns an [E, N] (x, y) Lv03 point.
    """
    result_list = arcgeo.project([arcgeo.Point({"x" : latlonPoint[1], "y" : latlonPoint[0]})], '4326', '21781')
    result = result_list[0]
    return [result['x'], result['y']]
예제 #2
0
def swiss_to_latlon_batch(swissPoints):
    """
    Takes a list of [E, N] (x, y) Lv03 points and returns a list of [lat, lon] (y, x) points.
    """
    chpts = [arcgeo.Point({"x" : swissPoint[0], "y" : swissPoint[1]}) for swissPoint in swissPoints]
    result_list = arcgeo.project(chpts, '21781', '4326')
    return [[result['y'], result['x']] for result in result_list]
예제 #3
0
def convert(geojson, wkid=4326):
    esri_json = {'spatialReference': {'wkid': wkid}}
    if geojson['type'] == 'Point':
        esri_json['x'] = geojson['coordinates'][0]
        esri_json['y'] = geojson['coordinates'][1]
        return geometry.Point(esri_json)

    elif geojson['type'] == 'MultiPoint':
        esri_json['points'] = geojson['coordinates']
        return geometry.MultiPoint(esri_json)

    elif geojson['type'] == 'LineString':
        esri_json['paths'] = [geojson['coordinates']]
        return geometry.Polyline(esri_json)

    elif geojson['type'] == 'MultiLineString':
        esri_json['paths'] = geojson['coordinates']
        return geometry.Polyline(esri_json)

    elif geojson['type'] == 'Polygon':
        esri_json['rings'] = geojson['coordinates']
        return geometry.Polygon(esri_json)

    elif geojson['type'] == 'MultiPolygon':
        esri_json['rings'] = [
            line for polygon in geojson['coordinates'] for line in polygon
        ]
        return geometry.Polygon(esri_json)

    else:
        msg = 'Type {} is not supported.'.format(geojson['type'])
        raise UnsupportedGeometryType(msg)
예제 #4
0
def getDistrict(x, y):
    pt = geometry.Point({"x": x, "y": y, "spatialReference": {"wkid": 4326}})
    dist_filter = geometry.filters.intersects(pt)
    q = feature_layer.query(where='1=1', geometry_filter=dist_filter)
    if len(q.features) == 0:
        return None  #if the area is not in georgia, return None
    else:
        return int(q.features[0].attributes['DISTRICT'])  #district number
예제 #5
0
def add_feature(coords, fl, placename, placetype):
    """ Add feature using the arcgis for python api"""
    geom = geometry.Point(coords)
    feature = features.Feature(geometry=geom,
                               attributes={
                                   'name': placename,
                                   'type': placetype
                               })
    resp = fl.edit_features(adds=[feature])
    logger.info(resp)
    return resp['addResults'][0]['objectId']
예제 #6
0
def create_feature(_map, location):
    try:
        object_id = 1
        point = geometry.Point(location)
        feature = features.Feature(geometry=point,
                                   attributes={
                                       'OBJECTID': object_id,
                                       'PARK_NAME': 'My Park',
                                       'TRL_NAME': 'Foobar Trail',
                                       'ELEV_FT': '5000'
                                   })

        trailheads_layer.edit_features(adds=[feature])
        _map.draw(point)

    except Exception as e:
        print("Couldn't create the feature. {}".format(str(e)))