How can I get a layer with UTM projection

Dec 14, 2015 at 9:57 AM
Hi, I have a blank layer, Created as a vectorLayer with a BlankProvider (which is just a envelope from -180 to 180 from east to west and the same from south to north). ESRI return 0.

I need to set CoordinateTransform as this.

ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            lay.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
            //lay.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);
First Question is why i need to put CoordinateTransformation? If I don´t set that I can't receive coordinates.

My second question is how i can to set this blanklayer as a UTM projection but not just for one UTM zone, what i need is a global blank layer with all the UTM projections that return coordinates it this possible??

Thanks.
Coordinator
Dec 15, 2015 at 7:31 AM
I'm sorry, I have no clue what you are trying to achieve.
Dec 15, 2015 at 8:00 AM
First I want to know why is necessary to add the CoordinateTransformation, when i upload a shp file with WGS84 (lat,lon) i can receive coordinates from imageToWorld().
without setting CoordinateTransformation.
Why I need to set the CoordinateTransformation in my Blank Layer? Or I have to put a coordinate system in order to receive coordinates??

So when i upload a WGS84 lat/lon shapefile i receive coordinates from -180 to 180, but what i want is to reproject my blank layer to get UTM pointsnot just Coordinates(lat/lon).
Coordinator
Dec 15, 2015 at 10:05 AM
You only need to apply a coordinate transformation if
  • your input data sources do not have the same coordinate system
  • you do not like the coordinate system of your input data, e.g, you have lat/long but want some projected coordinate system
You say your shapefile has lat/long and you want UTM, then you need coordinate transformation.

I don't know what the purpose of the blank layer is.
Dec 15, 2015 at 11:56 AM
The blank layer is just a layer with no geoData, just for offline purposes or when no shapefile file available.

So If I have this blank layer, but how i can set WGS84 lat/lon coordinates to it?
This is my BlankProvider to this blanklayer.
public class BlankProvider: IProvider
    {
        #region Private Constants
        private const double DEFAULT_X_MIN = -180;
        private const double DEFAULT_X_MAX =  180;
        private const double DEFAULT_Y_MIN = -180;
        private const double DEFAULT_Y_MAX =  180;

        private const string DEFAULT_CONNECTION_ID = "BlankProvider";
        #endregion
        #region Private Variables
        private Envelope envelope;
        #endregion
        
        public BlankProvider()
        {
            envelope = new Envelope(DEFAULT_X_MIN, DEFAULT_X_MAX, DEFAULT_Y_MIN, DEFAULT_Y_MAX);
        }
        public string ConnectionID 
        {
            get
            {
                return DEFAULT_CONNECTION_ID;
            }
        }

        /// <summary>
        /// Returns true if the datasource is currently open
        /// </summary>
       public bool IsOpen 
       {
           get
           {
               return true;
           }
           
       }

        /// <summary>
        /// The spatial reference ID (CRS)
        /// </summary>
       public int SRID 
        { 
            get
            {
                return 0;
            }
            set
            {

            }
           
        
        }

        /// <summary>
        /// Gets the features within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns>Features within the specified <see cref="GeoAPI.Geometries.Envelope"/></returns>
        public Collection<IGeometry> GetGeometriesInView(Envelope bbox)
        {
            return new Collection<IGeometry>();
        }

        /// <summary>
        /// Returns all objects whose <see cref="GeoAPI.Geometries.Envelope"/> intersects 'bbox'.
        /// </summary>
        /// <remarks>
        /// This method is usually much faster than the QueryFeatures method, because intersection tests
        /// are performed on objects simplified by their <see cref="GeoAPI.Geometries.Envelope"/>, and using the Spatial Index
        /// </remarks>
        /// <param name="bbox">Box that objects should intersect</param>
        /// <returns></returns>
        public Collection<uint> GetObjectIDsInView(Envelope bbox)
        {
            return new Collection<uint>() ;
        }

        /// <summary>
        /// Returns the geometry corresponding to the Object ID
        /// </summary>
        /// <param name="oid">Object ID</param>
        /// <returns>geometry</returns>
        public IGeometry GetGeometryByID(uint oid)
        {
            return null;
        }

        /// <summary>
        /// Returns the data associated with all the geometries that are intersected by 'geom'
        /// </summary>
        /// <param name="geom">Geometry to intersect with</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
        {

        }

        /// <summary>
        /// Returns the data associated with all the geometries that are intersected by 'geom'
        /// </summary>
        /// <param name="box">Geometry to intersect with</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds)
        {

        }

        /// <summary>
        /// Returns the number of features in the dataset
        /// </summary>
        /// <returns>number of features</returns>
        public int GetFeatureCount()
        {
            return 0;
        }

        /// <summary>
        /// Returns a <see cref="SharpMap.Data.FeatureDataRow"/> based on a RowID
        /// </summary>
        /// <param name="rowId">The id of the row.</param>
        /// <returns>datarow</returns>
        public FeatureDataRow GetFeature(uint rowId)
        {
            return null;
        }

        /// <summary>
        /// <see cref="Envelope"/> of dataset
        /// </summary>
        /// <returns>The 2d extent of the layer</returns>
        public Envelope GetExtents()
        {
            return envelope;
        }

        /// <summary>
        /// Opens the datasource
        /// </summary>
        public void Open()
        {

        }

        /// <summary>
        /// Closes the datasource
        /// </summary>
        public void Close()
        {

        }

        public void Dispose()
        {

        }
    }
Coordinator
Dec 15, 2015 at 1:19 PM
If it is supposed to be a WGS84 provider I'd return 4326 for SRID and change the DEFAULT_Y_[MIN|MAX] to [-90|90].
Then you can set the coordinate transformation on the VectorLayer that uses this provider.
Dec 15, 2015 at 7:23 PM
But maybe i don't understand correctly, if the provider has a WGS84 coordinate system, why i would have to put a coordinate transformation if i want a WGS84 also in the layer?

If i need a coordinate transformation Which one should be for a WGS84 (lat/lon) ?

Thank you so much for your help.
Coordinator
Dec 16, 2015 at 6:35 AM
If your data is WGS84 and you want it that way, you don't need CoordinateTransformation.