How to use the arcgis.geometry.filters 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 / sotd_indicators / indicators.py View on Github external
#     pass
        # else:
        #     diff = abs(enriched_pop - sample_total)
        #     if diff > 100:
        #         pop_diff.append(diff)
        #
        # tot_pop = enriched_pop if enriched_pop > 0 else sample_total
        # tot_pop = tot_pop if tot_pop > 0 else -1

        ##-----------------------------------------------------------------------------

        them_lyr = FeatureLayer(url=them_url, gis=them_gis)

        geom = Geometry(row[1].SHAPE).buffer(-.01)

        sp_filter = filters.intersects(geom, 4326)

        them_sdf = them_lyr.query(geometry_filter=sp_filter, return_all_records=True).df
        #print(them_sdf)


        if len(df_current) > 0:
            count = len(df_current)
            max_val = df_current[f_thm_acc].max()
            max_scale = 100 * (len(df_current[df_current[f_thm_acc] == max_val])/count)
            min_val = df_current[f_thm_acc].min()
            min_scale = 100 * (len(df_current[df_current[f_thm_acc] == min_val])/count)
            vc = df_current[f_thm_acc].value_counts()
            common = df_current[f_thm_acc].mode() # Used in MSP
            mean = df_current[f_thm_acc].mean()
            if len(common) > 0:
                common = common[0]
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_indicators / Indicator.py View on Github external
def set_selected(self, indicator):

        created = False
        out_sdf = None

        # Indicator Feature Layer
        indicator_url = self.__getattribute__(indicator + '_url')
        print(indicator_url)
        #data_fl = FeatureLayer(url=indicator_url, gis=self.gis_conn)

        # Enumerate Used to Leverage the Merge Method on the Data Frame.
        # Set the First and Merge the Remainder to the First.
        for idx, row in enumerate(self.grid_sdf.iterrows()):

            # Negative Buffer Used to Avoid Selecting More Than 1 Cell
            sp_filter = filters.intersects(
                Geometry(row[1].SHAPE).buffer(-.1),
                self.grid_wkid
            )

            if not indicator_url:
                df_current = SpatialDataFrame(
                    columns=field_schema.get(indicator),
                    geometry=[Geometry(json.loads(row[1].SHAPE.JSON))]
                )
                created = True

            else:
                # Negative Buffer to Select a Single Grid Cell
                sp_filter = filters.intersects(
                    Geometry(row[1].SHAPE).buffer(-.1),
                    self.grid_wkid
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_indicators / Indicator.py View on Github external
self.aoi_portal,
                    self.aoi_username,
                    self.aoi_password
                )
            else:
                self.aoi_gis = GIS()


            fl = FeatureLayer(
                self.aoi_filter_url,
                gis=self.aoi_gis
            )

            geometry = dict(fl.properties.extent)

            sp_filter = filters.intersects(
                geometry,
                geometry['spatialReference']
            )

            self.geometry_filter = sp_filter

        else:
            self.geometry_filter = None

        if not self.grid_url:
            raise Exception('Grid URL Not Set')
        else:

            dates = get_dates_in_range(int(self.lb_days))
            query_string = form_query_string(dates)
            print(query_string)
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_processor.py View on Github external
grid_sdf = grid_fl.query(return_all_records=return_all_records, where=where_clause).df

    geometry = grid_sdf.geometry
    sr = {'wkid':4326}
    sp_rel = "esriSpatialRelIntersects"

    for idx, row in enumerate(grid_sdf.iterrows()):
        geom = row[1].SHAPE

        new_geom = Geometry({
            "rings" : [[[geom.extent.upperRight.X-.1, geom.extent.lowerLeft.Y+.1], [geom.extent.lowerLeft.X+.1, geom.extent.lowerLeft.Y+.1], [geom.extent.lowerLeft.X+.1, geom.extent.upperRight.Y-.1], [geom.extent.upperRight.X-.1, geom.extent.upperRight.Y-.1], [geom.extent.upperRight.X-.1, geom.extent.lowerLeft.Y+.1]]],
            "spatialReference" : {"wkid" : 4326}
        })

        grid_filter = filters._filter(new_geom, sr, sp_rel)
        sp_filter = filters._filter(geom, sr, sp_rel)

        data_fl = FeatureLayer(url=config.features_url)
        #out_fields=in_fields,
        data_sdf = data_fl.query(geometry_filter=sp_filter,return_geometry=True,
            return_all_records=return_all_records).df

        print('Processing Completeness')
        #bounding_box = '(37.708132, -122.513617, 37.832132, -122.349607)'
        bounding_box = '(' + \
                    str(geom.extent.lowerLeft.Y) + ',' + \
                    str(geom.extent.lowerLeft.X) + ',' + \
                    str(geom.extent.upperRight.Y) + ',' + \
                    str(geom.extent.upperRight.X) + ')'

        osm_sdf = runner.gen_osm_sdf('line', bounding_box, osm_tag='highway', present=True)
        completeness_sdf, completeness_fl = comp.completeness(gis, osm_sdf,
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_processor.py View on Github external
grid_fl = FeatureLayer(url=config.grid_url)
    grid_sdf = grid_fl.query(return_all_records=return_all_records, where=where_clause).df

    geometry = grid_sdf.geometry
    sr = {'wkid':4326}
    sp_rel = "esriSpatialRelIntersects"

    for idx, row in enumerate(grid_sdf.iterrows()):
        geom = row[1].SHAPE

        new_geom = Geometry({
            "rings" : [[[geom.extent.upperRight.X-.1, geom.extent.lowerLeft.Y+.1], [geom.extent.lowerLeft.X+.1, geom.extent.lowerLeft.Y+.1], [geom.extent.lowerLeft.X+.1, geom.extent.upperRight.Y-.1], [geom.extent.upperRight.X-.1, geom.extent.upperRight.Y-.1], [geom.extent.upperRight.X-.1, geom.extent.lowerLeft.Y+.1]]],
            "spatialReference" : {"wkid" : 4326}
        })

        grid_filter = filters._filter(new_geom, sr, sp_rel)
        sp_filter = filters._filter(geom, sr, sp_rel)

        data_fl = FeatureLayer(url=config.features_url)
        #out_fields=in_fields,
        data_sdf = data_fl.query(geometry_filter=sp_filter,return_geometry=True,
            return_all_records=return_all_records).df

        print('Processing Completeness')
        #bounding_box = '(37.708132, -122.513617, 37.832132, -122.349607)'
        bounding_box = '(' + \
                    str(geom.extent.lowerLeft.Y) + ',' + \
                    str(geom.extent.lowerLeft.X) + ',' + \
                    str(geom.extent.upperRight.Y) + ',' + \
                    str(geom.extent.upperRight.X) + ')'

        osm_sdf = runner.gen_osm_sdf('line', bounding_box, osm_tag='highway', present=True)