POST
|
Hi Angela, the migration will be from ArcGIS 9.3 to ArcGIS 10.3. Do we have to code the migration or there is already a tool in ArcGIS 10.3 that can do the job? -Leo
... View more
02-26-2016
12:39 AM
|
0
|
0
|
341
|
POST
|
Hi ALL, I have a task to migrate the existing enterprise geodatabase in ArcGIS 9.x to ArcGIS 10.x as part of the system migration. What is the practical way to do this? Can I just upgrade the database to ArcGIS 10.x or I really have to copy the whole database to a newer version using ArcSDE. Can you also share with me any blog sites or other materials that I can use using ArcSDE for this purpose. Thanks.
... View more
02-24-2016
11:11 PM
|
0
|
2
|
2056
|
POST
|
Hi Luke, Currently I am using 12GB RAM but my Python is only 32bit. The reason why is that I have a problem before installing 64-bit GDAL for python. I tried your suggestion but I get errors in nrows saying not defined. Did I get the syntax/expression right? import arcpy from arcpy.sa import * import os, sys import numpy as np arcpy.CheckOutExtension("Spatial") stack = np.zeros((2,4800,4800),dtype=np.int) i=0 ws = 'G:/Test/Raster' for folder, subs, files in os.walk(ws): for fname in files: stack[i,nrows,ncols] = arcpy.RasterToNumPyArray(os.path.join(folder,fname)) By the way Luke, dividing the time series by tile is a good way. I have seen some of the script in R they do such technique for signal processing. Can you guide me how to approach this tiling method in Python? Thanks, -Leo
... View more
09-23-2015
06:32 PM
|
0
|
1
|
1068
|
POST
|
My intention is to stack my 2D array created from my MODIS rasters using numpy dstack. After that, I hope to implement savitzky-golay filtering algorithm from scipy signal processing so I think it is better to stack my 2D array to access the time series values of a particular pixel. Right now, I am just testing for 10 MODIS rasters (but later on will use my whole dataset -- approx 800 rasters (15 years of data)) only to test how should I create my script. So my initial workflow is to: 1) Access my raster files 2) For each file I need to convert it to a 2D array using RasterToNumPyArray 3) Append all those created 2D arrays to a list, and 4) Implement numpy.dstack() to stack my 2D arrays and hopefully I can begin some analysis. I am getting an error in the 4th step (it says memory error) -- converting my list of 2D arrays to a stack (please see script 1 below) but if I revise my script and load in dstack using the index of each element in my 2D array it runs okay. Could you guide how to approach my problem. I am just building my script so for now its not so much. please see below. Thanks. Script 1 import arcpy
from arcpy.sa import *
import os, sys
import numpy as np
from scipy.signal import savgol_filter
arcpy.CheckOutExtension("Spatial")
rasters = []
ws = 'G:/Test/Raster'
for folder, subs, files in os.walk(ws):
for filename in files:
aSrc = arcpy.RasterToNumPyArray(os.path.join(folder,filename))
rasters.append(aSrc)
stackRast = np.dstack(rasters) Script 2 import arcpy
from arcpy.sa import *
import os, sys
import numpy as np
from scipy.signal import savgol_filter
arcpy.CheckOutExtension("Spatial")
rasters = []
ws = 'G:/Test/Raster'
for folder, subs, files in os.walk(ws):
for filename in files:
aSrc = arcpy.RasterToNumPyArray(os.path.join(folder,filename))
rasters.append(aSrc)
stack = np.dstack((rasters[0], rasters[1], rasters[2], rasters[3], rasters[4], rasters[5],rasters[6], rasters[7], rasters[8], rasters[9]))
... View more
09-22-2015
07:32 PM
|
0
|
3
|
5609
|
POST
|
Dear ArcPy/Python Users, I am working on four MODIS datasets on the same tile. I reclassified the map into boolean (1 and 0) based on some criteria. My objective is to have a reclassified map which contains some values based on the combination of values for each pixel from my four MODIS dataset. For instance, each pixel of my four rasters would contain one of the possible combinations, i.e., (1,1,0,0) the values are based on the sequence of my rasters -- (pixel value raster 1, pixel value raster 2, ...). How can I convert this to 1100? Another example would be: >>> a = np.array([1,2,3,4]) >>> b = np.array([5,6,7,8]) >>> c = np.array([9,10,11,12]) >>> d = np.array([4,7,8,9]) >>> x array([[[ 1, 5, 9, 4], [ 2, 6, 10, 7], [ 3, 7, 11, 8], [ 4, 8, 12, 9]]]) convert the items to 1594, 26107, 37118, 48129 then for instance 1594 will be reclassified to say 2120 The reason is that, I have a dictionary variable (see below) which will reclassify the values for each possible combination. So in the end I will have an array of, i.e., from 1100 to 2120. The corresponding values are representative on the number of occurrence and the sequence of that event. For instance the 1100 will be reclassified into 2120 -- this means the event of interest occurred twice in week 1 and week 2. {1000:1100, 0100:1200, 0010:0130, 0001:1400, 1001:2140, 1100:2120, 0110:2230, 0011:2340, 1011:3134, 1101:3124, 1110:3123, 0111:3234, 1111:4111, 0000:1 255,255,255,255 = 0} Here is the code that I am trying to complete and run but I am stuck now: # import arcpy module of arcgis
import arcpy, os, sys
from arcpy import env
# import spatial extension
from arcpy.sa import *
arcpy.env.overwriteOutput = True
# activate spatial extension
arcpy.CheckOutExtension("Spatial")
# environment settings
arcpy.env.extent = "MAXOF"
# workspace
arcpy.env.workspace = r'raster\directory'
rasters = arcpy.ListRasters("*", "tif")
# output workspace
out_ws = 'output/workspace/'
rastersCount = len(rasters)
counter = 0 # starting index
pixReclass = {1000:1100,
0100:1200,
0010:0130,
0001:1400,
1001:2140,
1100:2120,
0110:2230,
0011:2340,
1011:3134,
1101:3124,
1110:3123,
0111:3234,
1111:4111,
0000:0}
# compute dekad rasters
while counter < 4: # I am processing/testing only the first four rasters in my list
rast = []
rastMon = []
for i in range(counter,counter+4):
#print rasters
rast.append(rasters)
print "rasters:{}".format(rast)
print len(rast)
for r in rast:
name, ext = r.split(".")
crit_Out = out_ws + name + "_reclass.tif"
criteria = Raster(r) >= 0001
criteria.save(crit_Out)
print criteria
vRast = arcpy.RasterToNumPyArray(crit_Out)
rastMon.append(vRast)
print "number of array:{}".format(len(rastMon))
zipped = np.dstack((rastMon[0], rastMon[1], rastMon[2], rastMon[3]))
counter += 4 Hope that I made my query clear. Thanks for any advice and suggestion. -Leo Message was edited by: Leo Kris Palao
... View more
06-01-2015
12:33 AM
|
0
|
2
|
3701
|
POST
|
Dear Arcpy Users, I am reclassifying my raster data but I cannot get the output that I want. The case is, I have a floating point raster, in which, I want to reclassify it into categorical values. It is quite weird that some of my values are reclassified outside the range of values that I set. For instance, output categorical raster original raster 1 1.24941356103 1 0.944287159553 1 0.70514940818 0 0.0177492300117 0 2.72532446104e-07 250 -6.0889773748 This is the reclassification method that I want to do. -50 to -2.58 = 6 -2.58 to -1.96 = 5 -1.96 to -1.65 = 4 -1.65 to -1.29 = 3 -1.29 to 2.58 = 2 2.58 to 50 = 1 other pixels = No data Here is the code that I am running. import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
arcpy.env.extent = "MAXOF"
arcpy.env.workspace = r'directory\of\rasters\test'
rasters = arcpy.ListRasters("*","TIF")
out_ws = 'output/directory/Reclass/'
if not os.path.exists(out_ws):
os.makedirs(out_ws)
for raster in rasters:
name, ext = raster.split(".")
fileout = out_ws + name + "_reclass" + ".tif"
outReclass = Reclassify(raster, "Value", RemapRange([[-50.0,-2.58,6],[-2.58,-1.96,5],\
[-1.96,-1.65,4],[-1.65,-1.29,3],[-1.29,2.58,2],[2.58,50.0,1]]),"NODATA")
outReclass.save(fileout)
... View more
05-26-2015
11:00 PM
|
0
|
2
|
4828
|
POST
|
Hi Kishor, thanks for your suggestion. This confirms what I have in mind. Thank you very much. -Leo
... View more
04-20-2015
01:39 AM
|
0
|
0
|
893
|
POST
|
Hi ArcPy users, I have a bit of problem in my script. I am working with MODIS data, and I already have a stack of raster layers. I want to rescale my MODIS data (stack layers) but whenever I use the raster calculator or the divide function in Math the output is converted into single band. I have 10 bands(rasters) stacked in each of my TIFF files. out_Div = out_ws + "MOD_" + date_parse + "_clip_Geo_rescale" + ".tif"
outDivide = Divide(bands_WGS, 10000.00)
outDivide.save(out_Div) bands_WGS is a stack of 10 rasters. When I execute this the output is converted into a single band. Not a stack of rasters divided by 10000.00 Hope my query is clear. Thanks in advance for any help. -Leo
... View more
04-17-2015
03:20 AM
|
0
|
3
|
4939
|
POST
|
Hi Arcpy Users, Just want to inquire how can I properly install Pandas python package in ArcPy. I am having a hard time installing it. I just wanted to get the pandas to work so I can work easier with my CSV. Is this has something to do with my pip installation? Thanks, -Leo I am using this command: >>> pip install pandas and it returns this message: Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\lpalao>pip install pandas
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.2\Scripts\pip-script.py", line 9, in <module>
load_entry_point('pip==6.0.8', 'console_scripts', 'pip')()
File "build\bdist.win32\egg\pkg_resources.py", line 339, in load_entry_point
File "build\bdist.win32\egg\pkg_resources.py", line 2470, in load_entry_point
File "build\bdist.win32\egg\pkg_resources.py", line 2184, in load
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\__init__.py", line 13, in <
module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\utils\__init__.py", line 22
, in <module>
from pip._vendor import pkg_resources, six
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\_vendor\__init__.py", line
61, in load_module
__import__(name)
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\_vendor\pkg_resources\__ini
t__.py", line 79, in <module>
import pip._vendor.packaging.specifiers
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\_vendor\packaging\specifier
s.py", line 274, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Python27\ArcGIS10.2\lib\site-packages\pip-6.0.8-py2.7.egg\pip\_vendor\packaging\specifier
s.py", line 373, in Specifier
re.VERBOSE | re.IGNORECASE,
File "C:\Python27\ArcGIS10.2\lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\ArcGIS10.2\lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat Then when I import pandas (>>> import pandas) it returns the message below: >>> import numpy
>>> import pandas
numpy.ufunc has the wrong size, try recompiling
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\ArcGIS10.2\lib\site-packages\pandas-0.15.2-py2.7-win32.egg\pandas\__init__.py", line 7, in <module>
from . import hashtable, tslib, lib
File "pandas\src\numpy.pxd", line 865, in init pandas.hashtable (pandas\hashtable.c:22988)
ValueError: numpy.ufunc has the wrong size, try recompiling
... View more
03-02-2015
01:30 AM
|
0
|
5
|
9310
|
POST
|
Hi ArcPy users, Just would like to ask how can I use arcpy modules in PyScripter or Python2.7.9? It seems that PyScripter or Pyhton2.7.9 IDE/commandline cannot recognize the modules of arcpy. I want to have an integrated environment where I can use both Python2.7.9 modules and arcpy modules. What I have done so far: I created PYTHONPATH in system variables and set the following folder path, e.g. PYTHONPATH = C:\OSGeo4W\apps\Python27;C:\OSGeo4W\apps\qgis\bin;C:\OSGeo4W\apps\qgis\python;C:\Python27\ArcGISx6410.2;C:\Python27\ArcGISx6410.2\Scripts;C:\Python27\Python2.7.9;C:\Python27\Python2.7.9\Scripts;C:\Python27\ArcGISx6410.2\Lib;C:\Python27\ArcGISx6410.2\Lib\site-packages;C:\Python27\ArcGIS10.2\Lib\site-packages;C:\Python27\ArcGIS10.2\Lib I added C:\Python27\ArcGISx6410.2\Lib;C:\Python27\ArcGISx6410.2\Lib\site-packages in PATH in system variables When I open my Python 2.7.9 (installed separately) and run import arcpy I still got the message: ImportError: No module named arcpy. Thanks, -Leo
... View more
02-09-2015
05:49 PM
|
0
|
1
|
4031
|
POST
|
Hi ALL, I am doing a Temperature-Vegetation Dryness Index (TDVI) analysis using Normalized Difference Vegetation Index (NDVI) and Land Surface Temperature (LST) for drought assessment. I need to create a scatterplot of LST and NDVI. Can you help me do this in Python? or at least guide me on how to do this. Thanks, -Leo
... View more
01-08-2015
01:50 AM
|
0
|
1
|
5083
|
POST
|
Hi Python Users, I got stuck with my code trying to merge modis rasters (in tiff format) using Mosaic to New Raster. Any help will be much appreciated. I have time series NDVI rasters from MODIS data for 2014 for two tiles located in separate directory. What I would like to achieve is to automate the merging of the times series NDVI rasters using the Mosaic to New Raster tool in arcpy. MOD_h26v06_2014001_ndvi.tif merged with MOD_h27v06_2014001.tif . . . MOD_h26v06_2014297_ndvi.tif merged with MOD_h27v06_2014297.tif Any help/suggestion is very much appreciated. Below is the code that I am working on. Thanks, -Leo import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
raster1 = 'path/toRaster1'
arcpy.env.workspace = raster1
tile1 = [os.path.join(raster1, l) for l in arcpy.ListRasters("*2014*", "TIF")]
raster2 = 'path/toRaster2'
arcpy.env.workspace = raster2
tile2 = [os.path.join(raster2, r) for r in arcpy.ListRasters("*2014*", "TIF")]
out_ws = 'path/Out_rast'
# (input rasters,outputloc,name w/ ext, coor, pixeltype, cellsize, #of bands
# mosaic method, mosaic color map)
for h in range(0,46):
parse = l[18:25]
filename = "modis_evi_" + parse + ".tif"
mosaic = arcpy.MosaicToNewRaster_management(Raster(tile1 );Raster(tile2 ), out_ws, filename, "", "16_BIT_SIGNED", "", "1", "LAST","FIRST")
print mosaic
... View more
12-03-2014
01:59 AM
|
0
|
1
|
3697
|
POST
|
Hi Jeffrey and Codey, thanks for your reply and sorry for the delayed response and confusion on my inquiry. What I really want to use is the mosaic to new raster in arcpy -- Mosaics multiple raster datasets into a new raster dataset. I tried several codes and must have mistakenly copy and paste the latest code that I am using. Orignally this is the tool that I am trying to run:
arcpy.MosaicToNewRaster_management(Raster(h26v06 );Raster(h27v06 ), out_ws, filename, "", "16_BIT_SIGNED", "", "1", "LAST","FIRST")
I get an error while running this code. I cannot determine right now the exact error (error code) that I am getting (since I am running it in my office laptop), but if I can remember correctly, the error message is pointing me on the arguments that I put in the MosaicToNewRaster_management. I am suspecting that it has something to do with my first argument Raster(h26v06 );Raster(h27v06 ) . In this loop I am using the range function, that is why I am casting out the raster (Raster()) for each step, and referring it to the rasterlist that I created. Any help and suggestion is very much appreciated, -Leo
... View more
10-19-2014
12:04 AM
|
0
|
2
|
698
|
POST
|
Hi ALL, I want to mosaic a set of rasters in separate folders but I am stuck with my code. Basically, I have two sets of modis tiles located in two separate folders, and I want to create a mosaic dataset. case: Folder 1 = mod_h26v06_2012001.tif, mod_h26v06_2012009.tif, mod_h26v06_2012017.tif, mod_h26v06_2012025.tif,......., mod_h26v06_2012361.tif Folder 2 = mod_h27v06_2012001.tif, mod_h27v06_2012009.tif, mod_h27v06_2012017.tif, mod_h27v06_2012025.tif,......., mod_h27v06_2012361.tif What I want to do: mod_h26v06_2012001.tif merge with mod_h27v06_2012001.tif, ........, mod_h26v06_2012361.tif merge with mod_h27v06_2012361.tif This is my initial code:
# import necessary modules of ArcGIS
import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
# this will overwrite output. Important in testing codes
arcpy.env.overwriteOutput = True
# activate the spatial analyst extention of ArcGIS
arcpy.CheckOutExtension("Spatial")
# specify your workspace. This is where raster is stored
raster1 = 'X:/raster_ws'
arcpy.env.workspace = raster1
h26v06 = [os.path.join(raster1, l) for l in arcpy.ListRasters("*2012*", "TIF")]
raster2 = 'X:/raster_ws'
arcpy.env.workspace = raster2
h27v06 = [os.path.join(raster2, r) for r in arcpy.ListRasters("*2012*", "TIF")]
out_ws = 'X:/output_ws/'
# (input rasters,outputloc,name w/ ext, coor, pixeltype, cellsize, #of bands
# mosaic method, mosaic color map)
for h in range(0,46):
parse = l[18:25]
filename = "modis_evi_" + parse + ".tif" #'modis_8day_2012_{:03d}.tif'.format(h+1)
mosaic = arcpy.Mosaic_management(Raster(h26v06 );Raster(h27v06 ), out_ws, filename, "", "16_BIT_SIGNED", "", "1", "LAST","FIRST")
print mosaic
Any help is much appreciated. Thanks, -Leo
... View more
10-17-2014
02:23 AM
|
0
|
5
|
2061
|
POST
|
Hi Luke, thanks. This code is much simpler and very much readable. Thanks again for the help. -Leo
... View more
09-17-2014
05:45 PM
|
0
|
0
|
703
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|