How to use the arcgis.gis.GIS 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 / tests.py View on Github external
def setUpClass(cls):
        cls.indicator = Indicator()
        cls.indicator.load_config(r'C:\Users\jeff8977\Desktop\SOTD\config_no_urls.ini')
        cls.indicator.set_grid_sdf()
        cls.indicator.set_features()
        cls.indicator.gis_conn = GIS(
            'http://www.arcgis.com/home',
            'test',
            'test'
        )
github Esri / crowdsource-reporter-scripts / servicefunctions.py View on Github external
def main(configuration_file):

    try:
        with open(configuration_file) as configfile:
            cfg = json.load(configfile)

        gis = GIS(cfg['organization url'], cfg['username'], cfg['password'])

        # Get general id settings
        global id_settings
        id_settings = {}
        for option in cfg['id sequences']:
            id_settings[option['name']] = {'interval': int(option['interval']),
                                           'next value': int(option['next value']),
                                           'pattern': option['pattern']}

        # Get general moderation settings
        global modlists
        modlists = {}
        subs = cfg['moderation settings']['substitutions']
        for modlist in cfg['moderation settings']['lists']:
            words = [str(word).upper().strip() for word in modlist['words'].split(',')]
            modlists[modlist['filter name']] = build_expression(words, modlist['filter type'], subs)
github Esri / crowdsource-reporter-scripts / EnrichReports / enrich_reports.py View on Github external
def main():
    # Create log file
    with open(path.join(sys.path[0], 'attr_log.log'), 'a') as log:
        log.write('\n{}\n'.format(dt.now()))

        # connect to org/portal
        gis = GIS(orgURL, username, password)

        for service in services:
            try:
                # Connect to target layer
                fl = FeatureLayer(service['url'], gis)
                fl_fields = [field['name'] for field in fl.properties.fields]

                # get wkid of target layer for spatial queries
                wkid = fl.properties.extent.spatialReference.wkid

                for reflayer in reversed(service['enrichment layers']):  # reversed so the top llayer is processed last
                    # Connect to source layer
                    polyfeats = FeatureLayer(reflayer['url'], gis)

                    # test that source and target fields exist in source and target layers
                    poly_fields = [field['name'] for field in polyfeats.properties.fields]
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_indicators / Indicator.py View on Github external
url=self.portal,
                key_file=self.key,
                cert_file=self.pem,
                verify_cert=False
            )

        elif self.username != None and self.password != None:

            self.gis_conn = GIS(
                url=self.portal,
                username=self.username,
                password=self.password,
            )

        else:
            self.gis_conn = GIS()

        # Setting Publication GIS
        if self.pub_key != None and self.pub_pem != None:

            self.pub_gis_conn = GIS(
                url=self.pub_portal,
                key_file=self.pub_key,
                cert_file=self.pub_pem,
                verify_cert=False
            )
        elif self.pub_username != None and self.pub_password != None:

            self.pub_gis_conn = GIS(
                url=self.pub_portal,
                username=self.pub_username,
                password=self.pub_password,
github Esri / collector-tools / CollectorUtils / scripts / add_update_gnss_fields_python_api.py View on Github external
def searchItems_addGNSSMetadataFields(args_parser):
    # Search ItemIds
    gis = GIS(args_parser.url, args_parser.username, args_parser.password)
    
    arcpy.AddMessage("Signed into organization..")

    itemId = args_parser.itemId

    try:

        featureLayerItem = gis.content.get(itemId)

        # Construct a FeatureLayerCollection from the portal item.
        featureLayerCollection = FeatureLayerCollection.fromitem(featureLayerItem)

        # Extract fields from Feature layer service definition
        featureLayerFields = featureLayerCollection.manager.layers[args_parser.layerIndex].properties[
            'fields'] if args_parser.layerIndex else \
            featureLayerCollection.manager.layers[0].properties['fields']
github joshsharpheward / gis-administration / find_unused_services.py View on Github external
def main():
    # logs into active portal in ArcGIS Pro
    gis = GIS('pro')

    arcpy.AddMessage("Logged into {} as {}".format(arcpy.GetActivePortalURL(), gis.properties['user']['username']))

    # creates list of items of all map image, feature, vector tile and image services (up to 10000 of each) in active portal
    services = (gis.content.search(query="", item_type="Map Service", max_items=10000) +
                gis.content.search(query="", item_type="Feature Service", max_items=10000) +
                gis.content.search(query="", item_type="Vector Tile Service", max_items=10000) +
                gis.content.search(query="", item_type="Image Service", max_items=10000))

    arcpy.AddMessage('Searching webmaps in {}'.format(arcpy.GetActivePortalURL()))

    # creates list of items of all webmaps in active portal
    web_maps = gis.content.search(query="", item_type="Web Map", max_items = 10000)
    # loops through list of webmap items
    for item in web_maps:
        # creates a WebMap object from input webmap item
github ngageoint / state-of-the-data / state-of-the-data-for-webgis / sotd_indicators / Indicator.py View on Github external
def set_gis(self):

        # Set GeoEnrichment GIS Object
        if self.them_key != None and self.them_pem != None:

            self.them_gis_conn = GIS(
                url=self.them_portal,
                key_file=self.them_key,
                cert_file=self.them_pem,
                verify_cert=False
            )

        elif self.them_password != None and self.them_username != None:
            self.them_gis_conn = GIS(
                url=self.them_portal,
                username=self.them_username,
                password=self.them_password
            )

        else:
            self.them_gis_conn = GIS()