Friday, March 22, 2019

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

1 Comment

In my custom angular web application, I had to pull the data from different ArcGIS server environments, say Dev ArcGIS server and Test ArcGIS server environment, some of my items are directly referred from ArcGIS server services and some of them are from Enterprise portal referring the WebMapId and PortalId from both environment (Dev, Test). Servers are in federated environment.

To pull the data from different ArcGIS server environment, user must login in each environment. In addition, user must login to get inside the custom application and Enterprise AD Group was set to authenticate users on the custom web application and ArcGIS server environments. So, there will be 3 login attempts (1 –application itself, 2- Dev server/portal, 3- Test server/portal) to use the application, which doesn’t provide good user experience.

To improve the better application workflow, I decided to reduce the number of logins required in the application and use AD Username and Password captured during application login to generate token for each ArcGIS server environment. Here are some reference snippets to generate token from ArcGIS server and use tokens request parameter in ESRI JS API and Angular.


Step 1: Generate token and store tokens in session 


 devServerLogin(username, password){
     let portalTokenUrl = ....+'/portal/sharing/rest/generateToken'; //Federated evn.,  use Portal  to generate user token.

    if(username && password){
      this.httpClient.post(tokenUrl, this.getCredentials(username, password), this.getHttpOptions()).subscribe(esriResponse =>{
        sessionStorage.setItem('dev_access_token', esriResponse['token']);
        sessionStorage.setItem('dev_access_token_expires', esriResponse['expires']);
      });;
    }
  }

  private getCredentials(username, password){
    let expiration = 720; //1440 -> 60 minute * 24 = 1 day token , 720 ->  12hrs token 
    
let urlReferer = 'https://'+window.location.host+'/';     
 
 let tokenCredentials =  'username='+username+'&password='+password+'&f=json&expiration='+expiration+'&client=referer&referer='+urlReferer;

    return tokenCredentials;
  }

  private getHttpOptions(){
    let httpOptions = {
      headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded', }),
      withCredentials: true,            
    };
    return httpOptions;
  }

Friday, December 30, 2016

ESRI FeatureClass vs Feature Layer

Be The First To Comment
Feature Layer: A layer that references a set of feature data. Feature data represents geographic entities as points, lines, and polygons.

Feature Class:In ArcGIS, a collection of geographic features with the same geometry type (such as point, line, or polygon), the same attributes, and the same spatial reference. Feature classes can be stored in geodatabases, shapefiles, coverages, or other data formats. Feature classes allow homogeneous features to be grouped into a single unit for data storage purposes. For example, highways, primary roads, and secondary roads can be grouped into a line feature class named "roads." In a geodatabase, feature classes can also store annotation and dimensions.

Rasterized Feature Layer: A feature layer in ArcGlobe that exists as points, lines and polygons but is rendered as cell data. When layers are added to ArcGlobe, they may automatically be rendered in raster format to retain their cartographic symbology.

Tuesday, December 16, 2014

Free Opportunity to attend the ESRI USER Conference - 2015 User Conference Student Assistantship

Be The First To Comment

Tuesday, February 19, 2013

Python Scripting for ArcGIS

Be The First To Comment

Python Scripting for ArcGIS is a new text from Esri Press by Paul A. Zandbergen (2013). It isn’t the first Python book for the geospatial community or even focused on ArcGIS, but it is the first that has the Esri logo on it. Much like other recent books on Geo/Python we have seen, it focuses on integrating an introduction to Python with the industry specific materials. As Frank mentioned when he highlighted the book in a previous podcast, this allows users to gain exposure to Python, but it doesn’t fall back on the (in my opinion) bad habit of most programming texts of spending half of the book on the language and concepts before even getting to the application in the specific area. There is a time and place for that approach in Python specific books. When you add another software library to a book, then use it from the get go.

Thursday, February 7, 2013

Interactive Map of Freshwater Species

Be The First To Comment


"Freshwater Ecoregions of the World, (FEOW) provides a new global bio-geographic regionalization of the Earth's freshwater biodiversity.  Covering virtually all freshwater habitats on Earth, this first-ever ecoregion map, together with associated species data, is a useful tool for underpinning global and regional conservation planning efforts, particularly to identify outstanding and imperiled freshwater systems; for serving as a logical framework for large-scale conservation strategies; and for providing a global-scale knowledge base for increasing freshwater biogeographic literacy."


"Over a decade of work and contributions by more than 200 leading conservation scientists have produced a first-ever comprehensive map and database of the diversity of life in the world’s freshwater ecosystems. The map and associated fish data – a collaborative project between World Wildlife Fund and The Nature Conservancy." 

For the fish lovers, the map is so cool.  Since you all like fish....you might find it just as cool too!!!  It is interactive, click on an ecoregion, it shows threats, species etc.  User is able to change transparency on the image to show terrain behind the ecoregion.  


Oh yeah, there is a complete article that went along with it... 

Wednesday, November 23, 2011

Instructions for Creating KMZ Image Overlays from ArcGIS in Google Earth and Google Map

1 Comment
Creating a kmz image overlay

 1. Make sure the dataset you are working with has a geographic coordinate system (unprojected) with WGS84 as the datum. If not, you will need to reproject your data. If the coordinate system of your datasets is defined you can change the projection “on-the-fly”. To reproject on-the-fly, go to Layers then Click Properties and specify geographic with WGS84 datum as the coordinate system. However, I recommend reprojecting the actual GIS datasets (shapefiles, grids, etc.) because project-on-the-fly is not always very precise, particularly when dealing with datum transformations.

2. Switch to the layout view. Select a layout that matches the dimensions of your map as closely as possible. To keep the file sizes of your images small, try to leave as little empty space around the edges as possible. Right-click on the layout and select Page and Print Setup to change the layout size.

3. Right-click on the map and select Properties. Go to the Size and Position tab. Under Size, set the Width and Height to exactly match the Width and Height of your layout. Under Position, set X and Y both to zero. Go to the Frame tab and make sure that Border is set to .

4. Zoom and pan in the layout so that you have as little empty space at the edges as possible.

5. Right-click on the layout and select Properties. Go to the Data Frame tab. Under Fixed Extent, you will see the latitudes for the top and bottom of the current layout, and the longitudes for the left and right sides of the current layout. Write these numbers down or cut and paste them into a file. Do not change them!

6. Go to File then Click Export Map. Export the tile as a PNG image. Select the Resolution (in pixels per inch). Depending on the amount of detail in your map and the size of your layout, you may need to experiment with a variety of resolutions to achieve a good balance between image quality and image size. 200 pixels per inch is often a good place to start. On the Format tab set Color Mode to 24-bit True Color, set the Background Color to white, and set the Transparent Color to white as well. If you have white in your map, you may need to choose a different shade (perhaps grey) for both the Background Color and Transparent Color. Do not check Clip Output to Graphics Extent. Click Save to export your file.
7. Open Google Earth

8. Select Add then Click Image Overlay

9. In the New Image Overlay box, type in a name for your overlay and use the Browse button to link to the image that you exported. You can use the Transparency slider to adjust the opacity of the overlay. Add a Description if you like.

10. Go to the Location tab and type or paste in the boundary coordinates of your layout that you saved in step 5. Be sure to include the negative sign for west latitudes. Click on OK.

11. You should see the name of your new image overlay under your Places in Google Earth. Right-click on it and select Save Place As… to save it as a kmz file. Once you have saved the kmz file, you can delete the temporary image overlay. You can double-click on your kmz file to open it in Google Earth,or use File then Click Open from the Google Earth menu.

Modifying a kmz image overlay

 1. You can use a program such as 7-zip to open the kmz archive. Inside you will find a KML file entitled doc.kml, and a subfolder that contains your image. You can open the KML file with a text editor. Note that there are just a few tags here that tell Google Earth what to do with your image. There is a tag. The tag has a code that specifies the amount of transparency in the overlay. The tag identifies the image to be overlaid. Thetab identified the bounding coordinates of the image.

2. You can create new kmz files by modifying this existing file. You can make a copy of the existing KMZ file, use 7-zip to remove the image1.png image and replace it with a image2.png image, and then use a text editor to modify the and tags in the kml file. Even if you have a new image has different bounding coordinates, you can edit them directly in the kmz file rather than using the New Image Overlay tool in Google Earth.

3. You can also add a legend or other graphics as screen overlays that are attached to a particular location on the screen (for example, the lower left corner) rather than a particular geographic location on the Earth’s surface.

4. There are various ways to export a legend from ArcGIS to a PNG file. One approach is to export the legend as part of a larger map graphic and then clip it out using a graphics program. Alternately, you can “trick” ArcGIS into letting you export the legend directly. Make sure your map symbology is set up the way that you want it displayed in the legend (it should match the map graphic that you have already exported). Set up your layout dimensions to match the size of your exported graphic (e.g., 1.5 x 1.5 inches). It can help to Insert then Click Legend into your layout first to get an idea of its dimensions. Your legend should fill up the layout and leave minimal whitespace at the edges. Right-click on the legend and choose Convert to Graphics. Then you can uncheck the map layers in the Table of Contents and you will only see the legend. You can now export the layout to a PNG file like you did with the map image. The only difference is that you should set the Background Color to white and the Transparent Color to No Color.

Thursday, October 13, 2011

DIVA GIS

Be The First To Comment
Today, I was working on Shapefiles from Australia and Nepal for my biodiversity research. I found DIVA GIS is useful for the scientist and students who can't afford ESRI's ArcGIS suite. DIVA-GIS is particularly useful for mapping and analyzing biodiversity data, such as the distribution of species, or other 'point-distributions'. It reads and write standard data formats such as ESRI shapefiles, so interoperability is not a problem. DIVA-GIS runs on Windows and (with minor effort) on Mac OSX.

Thursday, July 7, 2011

Cloud-based GIS application : ESRI Community Analyst

Be The First To Comment
Community Analyst includes demographic, health, economic, education, and business data variables to help users develop informed strategies for policy creation and critical resource allocation. Decisions such as matching health care clinics to areas with the greatest need or allocating infrastructure funding for maximum community impact can now be made and supported using customizable reports and maps more.
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me