AnsweredAssumed Answered

help with fishnet

Question asked by bcelik_83 on Oct 5, 2014

I am new on arcgis. Here is short description what i am doing. I am trying to get data from night lights that is taken from satellites.

I am trying to get city level data for turkey. I can get it by selecting each city by one by one.

Here is the steps i am doing. Select-clip-create fishnet-convert from raster to polygon-clip(again) and get zonal statistic as table. I can do these city by city.

However i want to do it by using python. I can do it by using model builder. I can export the python script.

But when i want to change the values for another city, this time create fish net step in python is not getting XY coordinate values automatically.

Because when i do it one by one, it gets values automatically.

 

here is the command that i created and run from model builder.

 

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

# deneme.py

# Created on: 2014-10-05 12:47:05.00000

#   (generated by ArcGIS/ModelBuilder)

# Description:

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

 

# Import arcpy module

import arcpy

 

# Check out any necessary licenses

arcpy.CheckOutExtension("spatial")

 

# Local variables:

Turkiye = "Turkiye\\Turkiye"

turkiye_lights2012 = "turkiye_lights2012"

turkiye_lights2012_Clip21__2_ = "turkiye_lights2012_Clip21"

turkiye_lights2012_Clip21 = "C:\\Users\\Bilalce\\Documents\\ArcGIS\\Default.gdb\\turkiye_lights2012_Clip21"

Turkiye__2_ = "Turkiye\\Turkiye"

Tur_81_2012 = "C:\\Users\\Bilalce\\Documents\\ArcGIS\\Default.gdb\\Tur_81_2012"

RasterT_turkiy19 = "C:\\Users\\Bilalce\\Documents\\ArcGIS\\Default.gdb\\RasterT_turkiy19"

Tur_81_2012_Clip = "C:\\Users\\Bilalce\\Documents\\ArcGIS\\Default.gdb\\Tur_81_2012_Clip"

ZonalSt_Tur_81_1 = "C:\\Users\\Bilalce\\Documents\\ArcGIS\\Default.gdb\\ZonalSt_Tur_81_1"

 

# Process: Create Fishnet

arcpy.CreateFishnet_management(Tur_81_2012, "30.82083249005 40.61250013755", "30.82083249005 50.61250013755", "0.1", "0.1", "0", "0", "31.77083248625 41.12083346885", "NO_LABELS", "turkiye_lights2012_Clip21", "POLYGON")

 

# Process: Raster to Polygon

arcpy.RasterToPolygon_conversion(turkiye_lights2012_Clip21__2_, RasterT_turkiy19, "NO_SIMPLIFY", "Value")

 

# Process: Clip (2)

arcpy.Clip_analysis(Tur_81_2012, RasterT_turkiy19, Tur_81_2012_Clip, "")

 

# Process: Select Layer By Attribute

arcpy.SelectLayerByAttribute_management(Turkiye, "NEW_SELECTION", "\"IL\" = '81'")

 

# Process: Clip

arcpy.Clip_management(turkiye_lights2012, "25.6673999987543 35.8112000003457 44.8215000005126 42.1055999984562", turkiye_lights2012_Clip21, Turkiye__2_, "255", "ClippingGeometry", "NO_MAINTAIN_EXTENT")

 

# Process: Zonal Statistics as Table

arcpy.gp.ZonalStatisticsAsTable_sa(Tur_81_2012, "OID", turkiye_lights2012_Clip21, ZonalSt_Tur_81_1, "DATA", "MEAN")

 

 

You can see what i mean on the left side. When i do one by one, in the create fish net step, it is getting coordinates automatically after i chose input layer. However when i try to do it, i dont know which values to put. And it is giving me an error.

 

Thank you so much

 

fishnetnew.jpg

Outcomes