Giter Club home page Giter Club logo

esri / mdcs-py Goto Github PK

View Code? Open in Web Editor NEW
62.0 32.0 29.0 18.75 MB

MDCS is an acronym for Mosaic Dataset Configuration Script and is the entry point to a collection of Python classes/libraries that could be consumed by a Python client application to complete a given workflow for creating a mosaic dataset, populating it with data, and setting all required/desired parameters.

License: Apache License 2.0

Python 97.77% Batchfile 0.70% Jupyter Notebook 1.53%
data-management python mosaic-datasets workflow imagery rasters image raster

mdcs-py's Introduction

mdcs-py

The Mosaic Dataset Configuration Script (MDCS) is a Python script that reads parameters stored in an xml file in order to create, configure, and populate a mosaic dataset.

If you want to try out MDCS, review the documentation included in the repo for instructions, and download the suggested sample data from ArcGIS Online.

This repo also contains MDTools, a command line tool that simplifies some common management tasks when working with rasters in a mosaic dataset.

Features

  • Automate the creation of multiple mosaic datasets
  • Configure multiple mosaic datasets using XML files
  • Built-in verbose reporting and logging system
  • Command line usage via batch files
  • Compatible with ArcMap 10.1+ and ArcGIS Pro 1.0+ (MDTools requires ArcMap 10.6.1+ or ArcGIS Pro 2.2+)
  • Use MDTools to do the following:
    • Embed raster proxies in a mosaic dataset
    • Perform search and replace for embedded raster proxy strings
    • Export file locations to a text file for rasters in a mosaic dataset in a given area of interest (AOI) and with a specific cell size

Instructions

  1. Download the ZIP file (called mdcs-py-master.zip)
  2. Create a folder called Image_Mgmt_Workflows in the root of your C: drive
  3. Unzip the contents of the MDCS ZIP file into the Image_Mgmt_Workflows folder

To get started with MDTools:

  1. Navigate to C:/Image_Mgmt_Workflows/mdcs-py/MDTools_Setup.zip
  2. Unzip the contents, then double-click MDTools_Setup.exe to install the tools.
  3. Refer to the MDTools documentation to get started.

Suggested Requirements

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Anyone and everyone is welcome to contribute.

Licensing

Copyright 2012 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

mdcs-py's People

Contributors

abhiataero avatar amrutha2410 avatar bikesbade avatar chamlika avatar ewindahl avatar imrankhan-pathan avatar punatipraveena avatar randallrebello avatar surabhijain123 avatar vedantbajaj96 avatar vijaygit02 avatar vjgit02 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdcs-py's Issues

Question: Need exmaple using MDCS in model builder

Hello Xin Xia,

Unfortunately I'm a consumer of this library as yourself, but I don't maintain it. It is managed by Esri's Imagery Workflows team. But you've got a good question that might help others so I'm going to post it as an issue on the Esri/mdcs-py repository, so the Workflows team will be able to check it out as well.

Thanks,
@mfunk

Hi Matt,

I found your email through the Mosaic Dataset Configuration Script (MDCS) GitHub. I have had success with running it on Command Prompt. However, what I really need is to make a tool out of the scripts to work in Model Builder. How do I go about loading all the separate python script files into a tool? How does the xml configuration file go into being used by a tool? Do they all need to be inputs to MDCS.py? Can this be done in a script tool or does it need to be done in a python toolbox tool?

Thank you,
Xin Xia

MDCS and optimize rasters

I'm using mdcs along with optimize rasters to create and then convert TIF overviews to MRF overviews. Then I want to run mdcs again to then swap the TIF overviews for the MRFs in the mosaic dataset. It works fine except the last step of adding the MRFs - below is the error and I've attached my batch file, screen shot of overviews folder and the remove raster config for mdcs. Any advice?

Adding rasters:
				<Error>
					<type>critical</type>
					<text>No new mosaic dataset items added to dataset (Test_Data). Verify the input data path/raster type is correct</text>
				</Error>
				<Error>

remove_raster_config.txt

example_batch.txt

overview_folder

moving to new AWS Zone

We have all our mrf-data in eu-west-1 but are currently moving it to eu-north-1 to get lower latency in Norway.
This means that all our mosaics with embedded proxies need to change the bucket reference inside the embedded proxies.
Currently the real path to the mrf-data is something like this: euwestbucket/subfolder/mrf/...
In the future it will look something like this: eunorthbucket/subfolder/mrf/...
I've tried to export paths with mdtools, but only the old external mrfproxy-paths are shown e.g.:
/servicedata/Markfuktighet_DTW/mrfproxy/Markfuktighet_DTW.Overviews/Ov_i04_L01_R000000AE_C0000003B.tif
So my guess is that I need to add some special formatting before the bucketname to allow the MD to know where to look.
But what formatting is that?

The link on README is not working

The link on README under "Resources - ElevationScripts from ArcGIS Resource Center" is not working

ElevationScripts from ArcGIS Resource Center
[http://www.arcgis.com/home/item.html?id=f1e1020f94ab40219cf0d2f22a62ceee/]
takes you to login request, then informs you that you do not have permisson.

It should point to:

[http://www.arcgis.com/home/item.html?id=d2a055e12af14258a931fdc3ecf2c8b4]
Python script for creating, configuring, and populating mosaic datasets.

Layer name when calculating a field can cause errors

The layer name created when calculating a field in line 934 of solutionsLib.py can cause an error when there are multiple calculations and they all run quickly. The name is based on the timestamp to the nearest second. When two calculations are closer than a second from each other, they can have the same layer name.

Also, the day is used in place of the month in the layer name. This probably doesn't cause any problems.

Proposed solution: change format of layer name to include milliseconds and also put month in the right place:

lyrName = 'lyr_%s_%s' % (str(self.m_base.m_last_AT_ObjectID),datetime.strftime(datetime.now(),"%Y%m%d%H%M%S%f"))

Add support to log the MDCS input command in the log file

Currently the default log files log the mosaic name , tool name and total time. It would be good to have the entire MDCS command logged in the log file as it will be useful to have it preserved in the log file especially when there are a lot of user variables used in the command line.

Update to documentation.

Need to update the pdf file with updated documentation.
File name MDCS.PDF
Delete MDCS_v5.pdf

Calculate Value expression / code block - 'not defined'

Having issues in making codeblocks work for the calculate value tool - followed the master.xml template but keep getting a Name Error:

	<CalculateValue>
                 <query></query>
		 <fieldName>CAPTURESTART</fieldName>
		 <expression>todate(!Name!)</expression>
		 <expression_type>PYTHON</expression_type>
		<code_block>"""def todate(value):\n import dateutil.parser as dparser\n  date = dparser.parse(next((x for x in (value.split("_")) if x[0].isdigit())), fuzzy=True, ignoretz=True)\n  return date"""</code_block>
	</CalculateValue>

Results in:

ERROR 000539: Traceback (most recent call last):
File "", line 1, in
NameError: name 'todate' is not defined

Can confirm same codeblock works in ArcPro calculate field. Any advice?

MDCS Create Reference Mosaic Dataset

Unable to create a Referenced MD using this command:

python.exe "C:\Image_Mgmt_Workflows\mdcs-py\scripts\MDCS.py" -i:"C:\Image_Mgmt_Workflows\mdcs-py\Parameter\Config\create_ref_md.xml"

With this template:

<?xml version="1.0" encoding="utf-8"?>
<Application>
	<Name>create_ref</Name>
	<Command>CR</Command>
	<Workspace>
		<WorkspacePath>C:\data\Services\Aerial\</WorkspacePath>
		<Geodatabase>Aerial_Public.gdb</Geodatabase>
		<MosaicDataset>
			<MosaicDatasetType>source</MosaicDatasetType>
			<Name>Aerial_Public</Name>
			<CreateReferencedMosaicDataset>
				<in_dataset>Aerial_Public</in_dataset>
				<out_mosaic_dataset>Aerial_Public_R</out_mosaic_dataset>
				<SRS></SRS>
				<number_of_bands></number_of_bands>
				<pixel_type></pixel_type>
				<where_clause>Latest = 1</where_clause>
				<in_template_dataset></in_template_dataset>
				<extent></extent>
				<select_using_features></select_using_features>
				<lod_field></lod_field>
				<minPS_field>MinPS</minPS_field>
				<maxPS_field>MaxPS</maxPS_field>
				<pixelSize></pixelSize>
				<build_boundary>BUILD_BOUNDARY</build_boundary>
			</CreateReferencedMosaicDataset>
			<AddRasters>
			</AddRasters>
			<Processes>
			</Processes>
		</MosaicDataset>
	</Workspace>
</Application>

There's no errors in the logfile, but no reference is created. I've tried hardcoding paths in <in_dataset> and <out_mosaic_dataset>, as well as using m: and p: in the console to override the mosaic and output but no luck. What am I missing?

MDTools.exe doc is inconsistent with tool help

Not urgent, but I noticed that when running the mdtools.exe executable without any arguments, the following arguments are shown:
image

This does not match the list of arguments (or the case/naming) from the PDF documentation - I assume the .exe just needs a quick update on the allowed params, since it includes a --PD argument that is not in the docs, and doesn't break out the --op, for example.

Use of variables in configuration script

When using a batch file to create a series of similar Mosaic datasets from the same configuration file (see extract below) I am not able to use variables in the batch and configuration files.

The variables seem to be ignored and the default value is always used. Also: how is a variable used when the variable name is non-unique in the configuration XML? (as is the case with <Name> which occurs twice at the top of the file). I am getting a
log-critical: Error: <Name> should be the first child-element in <MosaicDataset>
and then the MDCS script fails.

The help specifies the following syntax:
<defaultValue>;$<variableName>

which in my case for below configuration file looks as follows when I want the <MosaicDataset><Name>, <dataset_id> and <filter> variables to be dynamically specified:

c:\python27\ArcGIS10.3\python.exe C:\Image_Mgmt_Workflow\MDCS\scripts\mdcs.py -i:C:\Image_Mgmt_Workflow\MDCS\Parameter\Config\MPI_CreateMosaicDataset_GENERIC_AlbersEqualArea.xml -p:CatchMapper_MPI_AlbersEqualArea_MDCS_Demo_Ficticious$MosaicDataset/Name -p:CatchMapper_MPI_AlbersEqualArea_MDCS_Demo_Year01$dataset_id -p:year=1$filter

<?xml version="1.0" encoding="utf-8"?>
<Application>
  <Name>CatchMapper_MPI_AlbersEqualArea_MDCS_Demo_Year_GENERIC</Name>
  <Command>CM+AR+AF+BB+ERF+SP+CC+CV+AI+DO+BO</Command>
  <Workspace>
    <WorkspacePath>md</WorkspacePath>
    <Geodatabase>CatchMapper_MPI_Demo_YearlyMosaics</Geodatabase>
    <MosaicDataset>
     <Name>CatchMapper_MPI_AlbersEqualArea_MDCS_Demo_Year_GENERIC;$</Name>
      <MosaicDatasetType>Source</MosaicDatasetType>
      <SRS>PROJCS['NZ_Albers_Equal_Area',GEOGCS['GCS_WGS_1984',DATUM
['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM
['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER
['false_easting',0.0],PARAMETER['false_northing',0.0],PARAMETER
['central_meridian',175.0],PARAMETER['standard_parallel_1',-30.0],PARAMETER
['standard_parallel_2',-50.0],PARAMETER['latitude_of_origin',-40.0],UNIT['Meter',1.0]]</SRS>
      <num_bands>1</num_bands>
      <pixel_type>8_BIT_UNSIGNED</pixel_type>
      <AddRasters>
       <AddRaster>
         <dataset_id>MPI8bit_mosaics_Albers_Year05Grouped;$</dataset_id>
         <raster_type>Table @ C:\Image_Mgmt_Workflow\MDCS\MD\CatchMapper_MPI_Demo_YearlyMosaics.gdb\CatchMapper_MPI_AlbersEqualArea_MDCS_Demo\RasterType.OBJECTID=3</raster_type>
      <Sources>   <data_path>C:\Image_Mgmt_Workflow\MDCS\MD\CatchMapper_MPI_Demo.gdb\CatchMapper_MPI_AlbersEqualArea_MDCS_Demo</data_path>
      </Sources>
      <filter>year=1;$</filter>
      <duplicate_items_action>OVERWRITE_DUPLICATES</duplicate_items_action>
    </AddRaster>
    </AddRasters>

Thanks for any help on this.

Improvement - Setting projection horizontal and vertical by factory code

Currently when creating mosaic, I must use a well-known text string representation (like "PROJCS['WGS_1984_Web_Mercator_Auxiliar...."). But I would love to use Factory code directly (4326) and for both projections (horizontal and vertical)
Here is the possible solution to change script in CreateMD.py
image
and in xml file:
image

Cannot install the tool for ArcGIS Pro 2.5

Hi,

I've just downloaded and unzipped the tool.
When I ran the MDTool_Setup.exe, I only saw the option for ArcMap 10.7 components. However, while I have Pro 2.5 installed, I would like to utilize the tools in Pro.

I further looked up C:\Program Files\ArcGIS\Pro\bin, but I still failed to find the MDTool.

Is the tool support Pro 2.5?

Best,
April

SyntaxWarning: "is not" with a literal.

C:\Image_Mgmt_Workflows\MDCS\Sentinel-2-L2A-AWS\scripts\MDCS.py:208: SyntaxWarning: "is not" with a literal. Did you mean "!="?

if verMessage is not 'Ignore':

Where clause not working when used in XML

I am trying to use the RemoveRastersFromMosaicDataset and where_clause is supported in this. But when I put the following string in the where_clause for the StdTime column which is Date format it throughs an error: "not well-formed (invalid token): line 125, column 80"
The have tried:

  1. <where_clause>StdTime >= timestamp '2021-01-01 00:00:00' And StdTime <= timestamp '2021-01-10 00:00:00'</where_clause>
  2. <where_clause>"StdTime >= timestamp '2021-01-01 00:00:00' And StdTime <= timestamp '2021-01-10 00:00:00'"</where_clause>
    But when I use the same clause in the ArcPro using the Remove Rasters From Mosaic Dataset it work. See the screen grab below:
    image

Can we select capabilities while publishing the service?

Hi I just tried publishing a service using publishing commands and it worked.

I also wanted to select service Capabilities like WCS and WMS selected at time of publishing. tried to look in documentation and online did not find any clue how to pass Capabilities information into service definition or service definition draft.

publishing

Need a flat file structure as cannot iteratively add rasters stored in sub-folders

When using the 'Add Rasters' geoprocessing tool in ArcGIS Pro, you can provide a filepath to a folder that contains sub-folders where the images are stored. This is useful in cases where rasters are stored in groups (according to extents or grid references etc.), as it prevents a user from having to rearrange their file structure so that all of the images files are stored within a single folder.

The MDCS script does not currently allow for a filepath to a folder that contains sub-folders, instead, you have to provide a filepath to a folder that contains all of the rasters you want to add to a mosaic dataset. This means that a user needs to rearrange their file structure so that all the data is stored in a single folder, which can be quite time consuming.

Is there any way around this? Could this be handled as a bit of custom code in the MDCS_UC script?

Thanks,
Alex

Import Field Value command

Hello,
Import Field Value command ('IF' is its code) is not listed in the documentation ... I've found its node <<ImportFieldValues> into the "master.xml" file.
Anyway, I have seen that in its node there is the parameter .
Unfortunately this parameter is not considered by the script code of this command.
Looking at its content, I discovered that all fields of the join table are copied in to the the target table ( that is the footprint AMD table).
I think this is quite dangerous if the join table contains the same field name of the target table and you don't want to copy its content in to the target table ...

Is there any documentation on how to use data['response']

The file MDCS_UC.py have some examples among which I can find "sample02."

def sample02(self, data):
log = data['log'] # How to use logging within the user function.
log.Message('Returning multiple values', 0)
data['useResponse'] = True
data['response'] = ['msg0', 'msg1', 'msg2']
data['status'] = True # overall function status
return True # True must be returned if data['useResponse'] is required. data['response'] can be used to return multiple values.

Is there anyone who knows how to actually the values in data['response']?
Is there any documentation?

I'm building my own custom commands and want to return som values from such a command. Just need to know how to do it. :)

//Anders

Clip and Import Geometry

Hello,
I did not found any command to clip the geometry of boundary or footprints and replace their original geometry with the new clipped geometry.
Is it under development ?
Thanks a lot

logger module

Logger Module is not able to print messages with unicode characters in it with python 3.7.10 in ArcGIS Pro 2.8+
Affects all workflows using this module.

AWS S3 Bucket to Proxy not referencing

I am trying to publish a mosaic dataset on an EC2 machine (where our ESRI Enterprise and Image Server resides) using raster proxies created with the Optimize raster tool. The source .MRF images have been loaded into an AWS S3 bucket, I have provided the AWS credentials to the EC2 machine using the AWS CLI. The mosaic dataset fails to reference the S3 bucket. I have tried loading the mosaic using a .csv table and altering the source URL to include (\VSIS3\Http:\) and it still fails to reference the imagery. Is there anything obvious that I am missing that will solve this issue?

Manage Tile Cache fails if user tiling scheme is defined

Hello,
I'm experiencing a trouble in using the MTC processing code.
The Tile Cache seems to computed correctly (I can load and visualize) even if I get the bad message "Failed".
Looking at the code in the script SolutionLib.py I guess that the reason of the failure is due to two procedures that are not defined:
returnLevelDetails and modifyConfProperties.
Is it so ?
Thanks in advance for your attention
Giuseppe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.